diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-07 06:14:27 -0700 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-06-07 17:23:49 +0200 |
commit | 1bcdd25ce24f2b43f5c24f5a296ff8f81c7a0759 (patch) | |
tree | 18c3b73686a689e4d45d91280911320b39564fa1 | |
parent | 2abc531653e52f205c190be5ecd4a928b5482d5f (diff) | |
download | gitlab-ce-1bcdd25ce24f2b43f5c24f5a296ff8f81c7a0759.tar.gz |
Avoid sequential scans loading schema_migrations table when loading application settings
This was causing significant performance problems in production, and this commit
reverts to the original behavior.
-rw-r--r-- | lib/gitlab/current_settings.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 6cf7aa1bf0d..591a985a868 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -24,7 +24,20 @@ 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 ::Redis::BaseError, ::Errno::ENOENT, ::Errno::EADDRNOTAVAIL + # In case Redis isn't running or the Redis UNIX socket file is not available + end + end + + def uncached_application_settings return fake_application_settings unless connect_to_db? current_settings = ::ApplicationSetting.current |