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.
This commit is contained in:
Stan Hu 2018-06-07 06:14:27 -07:00 committed by Rémy Coutable
parent 2abc531653
commit 1bcdd25ce2
No known key found for this signature in database
GPG key ID: 98DFFD1C0C62B70B

View file

@ -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