summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-06-07 16:53:56 +0000
committerDouwe Maan <douwe@gitlab.com>2018-06-07 16:53:56 +0000
commit7b562c972713d19c2e537eb4df7cbe072ada8bbe (patch)
tree714ce9ee290920d7b2c39cf5b433d297051758fb /lib
parent5024c4aacc9ff9fd9d069e9d6b87ebdfe2ef356e (diff)
parent6afe6fa6bcb3bdb09bd49ba638a37af2a8c7a6ec (diff)
downloadgitlab-ce-7b562c972713d19c2e537eb4df7cbe072ada8bbe.tar.gz
Merge branch 'sh-fix-schema-migrations-seq-scans' into 'master'
Avoid sequential scans loading schema_migrations table when loading application settings See merge request gitlab-org/gitlab-ce!19541
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/current_settings.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 6cf7aa1bf0d..3cf35f499cd 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -24,7 +24,22 @@ module Gitlab
private
def ensure_application_settings!
+ cached_application_settings || uncached_application_settings
+ end
+
+ def cached_application_settings
return in_memory_application_settings if ENV['IN_MEMORY_APPLICATION_SETTINGS'] == 'true'
+
+ begin
+ ::ApplicationSetting.cached
+ rescue
+ # In case Redis isn't running
+ # or the Redis UNIX socket file is not available
+ # or the DB is not running (we use migrations in the cache key)
+ end
+ end
+
+ def uncached_application_settings
return fake_application_settings unless connect_to_db?
current_settings = ::ApplicationSetting.current