Skip to content
Snippets Groups Projects
Commit 474a42cf authored by Ariejan de Vroom's avatar Ariejan de Vroom
Browse files

Only load MySQL2Adapter connection fix is MySQL2 is available.

Useful for Sqlite or Postgres installations.
parent 4b96907e
No related branches found
No related tags found
No related merge requests found
module ActiveRecord::ConnectionAdapters
class Mysql2Adapter
alias_method :execute_without_retry, :execute
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
module ActiveRecord::ConnectionAdapters
class Mysql2Adapter
alias_method :execute_without_retry, :execute
 
def execute(*args)
execute_without_retry(*args)
rescue Mysql2::Error => e
if e.message =~ /server has gone away/i
warn "Server timed out, retrying"
reconnect!
retry
else
raise e
def execute(*args)
execute_without_retry(*args)
rescue Mysql2::Error => e
if e.message =~ /server has gone away/i
warn "Server timed out, retrying"
reconnect!
retry
else
raise e
end
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment