diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index e66e7768f2b9c9597bfca6aaa12286b7aeea7254..a6b2f14521c408d42d5f54d44eadde28db2a9d53 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -41,8 +41,11 @@ module Gitlab private def connect_to_db? + # When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised + active_db_connection = ActiveRecord::Base.connection.active? rescue false + ENV['USE_DB'] != 'false' && - ActiveRecord::Base.connection_pool.active_connection? && + active_db_connection && ActiveRecord::Base.connection.table_exists?('application_settings') rescue ActiveRecord::NoDatabaseError