Skip to content

Instantly share code, notes, and snippets.

@masterkain
Created January 3, 2010 23:09
Show Gist options
  • Save masterkain/268180 to your computer and use it in GitHub Desktop.
Save masterkain/268180 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment