gitlab-org--gitlab-foss/config/initializers/connection_fix.rb
Ariejan de Vroom 474a42cfbd Only load MySQL2Adapter connection fix is MySQL2 is available.
Useful for Sqlite or Postgres installations.
2012-03-27 16:59:25 +03:00

19 lines
No EOL
473 B
Ruby

if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
module ActiveRecord::ConnectionAdapters
class Mysql2Adapter
alias_method :execute_without_retry, :execute
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
end
end
end
end