Created
April 28, 2011 16:56
-
-
Save clifton/946747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::ConnectionAdapters::MysqlAdapter | |
def active? | |
true | |
end | |
def execute_with_retry_if_fail(*args) | |
execute_without_retry_if_fail(*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 | |
alias_method_chain :execute, :retry_if_fail | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment