Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2019-03-18 16:32:26 +0300
committerRémy Coutable <remy@rymai.me>2019-04-04 12:06:11 +0300
commitf37f28b962376843e7682dad15067edb131ecdd8 (patch)
tree9ffc89724cfc6d03123c152ea2b0c7f60d7ec72c /app/models/application_setting.rb
parenta6e9175fdd7790cc433ba49a85eaadbf75a3c8e9 (diff)
Fix race cond. in ApplicationSettingImplementation.create_from_defaults
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models/application_setting.rb')
-rw-r--r--app/models/application_setting.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 9e91e4ab4b9..7ec8505b33a 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -223,4 +223,11 @@ class ApplicationSetting < ApplicationRecord
reset_memoized_terms
end
after_commit :expire_performance_bar_allowed_user_ids_cache, if: -> { previous_changes.key?('performance_bar_allowed_group_id') }
+
+ def self.create_from_defaults
+ super
+ rescue ActiveRecord::RecordNotUnique
+ # We already have an ApplicationSetting record, so just return it.
+ current_without_cache
+ end
end