summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-03-15 13:12:00 -0700
committerStan Hu <stanhu@gmail.com>2018-03-15 13:13:00 -0700
commit272783be20927148d86b05a7e22f88b291c6dd93 (patch)
tree971ae72b5eee6a0d06fdaedb2cdc8c54e7f2b5ee /lib
parent4acbc9410d2d3f5624ebf9cf8850b189524d321d (diff)
downloadgitlab-ce-272783be20927148d86b05a7e22f88b291c6dd93.tar.gz
Cache table_exists?('application_settings') to reduce repeated schema reloadssh-cache-table-exists
Closes #43355
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/current_settings.rb2
-rw-r--r--lib/gitlab/database.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index b7c596a973d..e392a015b91 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -70,7 +70,7 @@ module Gitlab
active_db_connection = ActiveRecord::Base.connection.active? rescue false
active_db_connection &&
- ActiveRecord::Base.connection.table_exists?('application_settings')
+ Gitlab::Database.cached_table_exists?('application_settings')
rescue ActiveRecord::NoDatabaseError
false
end
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index d4fc69cb173..76501dd50e8 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -187,6 +187,11 @@ module Gitlab
connection.schema_cache.columns_hash(table_name).has_key?(column_name.to_s)
end
+ def self.cached_table_exists?(table_name)
+ # Rails 5 uses data_source_exists? instead of table_exists?
+ connection.schema_cache.table_exists?(table_name)
+ end
+
private_class_method :connection
def self.database_version