Added fix for "MySQL has gone away" errors with Resque workers.

This commit is contained in:
Ariejan de Vroom 2012-03-27 15:17:23 +02:00
parent 1647f46b1f
commit 3b4e7b315b

View file

@ -0,0 +1,17 @@
module ActiveRecord::ConnectionAdapters
class MysqlAdapter
alias_method :execute_without_retry, :execute
def execute(*args)
execute_without_retry(*args)
rescue ActiveRecord::StatementInvalid => e
if e.message =~ /server has gone away/i
warn "Server timed out, retrying"
reconnect!
retry
else
raise e
end
end
end
end