gitlabhq/config/initializers/connection_fix.rb

17 lines
376 B
Ruby
Raw Normal View History

module ActiveRecord::ConnectionAdapters
2012-03-27 15:42:23 +02:00
class Mysql2Adapter
alias_method :execute_without_retry, :execute
def execute(*args)
execute_without_retry(*args)
2012-03-27 15:42:23 +02:00
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
2012-03-27 15:42:23 +02:00
end