2012-03-27 15:59:25 +02:00
|
|
|
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
|
|
|
|
module ActiveRecord::ConnectionAdapters
|
|
|
|
class Mysql2Adapter
|
|
|
|
alias_method :execute_without_retry, :execute
|
2012-03-27 15:17:23 +02:00
|
|
|
|
2012-03-27 15:59:25 +02:00
|
|
|
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
|
2012-03-27 15:17:23 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-03-27 15:42:23 +02:00
|
|
|
end
|