Commit 78d84587 authored by DJ Mountney's avatar DJ Mountney

Only use RequestStore for current_application_settings during a request

This fixes an issue where the RequestStore was being populated with the settings in the unicorn master
during the rails initializers. Each forked worker would then start their first request with an uncleaned RequestStore.
parent f9bb9151
module Gitlab
module CurrentSettings
def current_application_settings
key = :current_application_settings
RequestStore.store[key] ||= begin
settings = nil
if RequestStore.active?
RequestStore.fetch(:current_application_settings) { ensure_application_settings! }
else
ensure_application_settings!
end
end
if connect_to_db?
settings = ::ApplicationSetting.current
settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration?
end
def ensure_application_settings!
settings = nil
settings || fake_application_settings
if connect_to_db?
settings = ::ApplicationSetting.current
settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration?
end
settings || fake_application_settings
end
def fake_application_settings
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment