diff options
author | Ariejan de Vroom <ariejan@ariejan.net> | 2012-03-27 16:59:25 +0300 |
---|---|---|
committer | Ariejan de Vroom <ariejan@ariejan.net> | 2012-03-27 16:59:25 +0300 |
commit | 474a42cfbd939f644eb5d900e447dae48142508a (patch) | |
tree | e07c3629965928a0c09c59a46ed9de833c93368c /config | |
parent | 4b96907e7cc7cef55034499c2d5c5d0998637c99 (diff) | |
download | gitlab-ce-474a42cfbd939f644eb5d900e447dae48142508a.tar.gz |
Only load MySQL2Adapter connection fix is MySQL2 is available.
Useful for Sqlite or Postgres installations.
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/connection_fix.rb | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/config/initializers/connection_fix.rb b/config/initializers/connection_fix.rb index d15b0c206cf..c29f6b11177 100644 --- a/config/initializers/connection_fix.rb +++ b/config/initializers/connection_fix.rb @@ -1,16 +1,18 @@ -module ActiveRecord::ConnectionAdapters - class Mysql2Adapter - alias_method :execute_without_retry, :execute +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 + 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 |