diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 21a97c8d7734f85b74dd68abdea65e1862c3f69a..eb6ddaac871bbce748e042889d926fbea687186e 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -259,7 +259,9 @@ class ApplicationSetting < ApplicationRecord after_commit :expire_performance_bar_allowed_user_ids_cache, if: -> { previous_changes.key?('performance_bar_allowed_group_id') } def self.create_from_defaults - super + transaction(requires_new: true) do + super + end rescue ActiveRecord::RecordNotUnique # We already have an ApplicationSetting record, so just return it. current_without_cache diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 3723c5ef7d71301fdef75a84022cb4f52dffc19f..4ea40e3c8ce349ea76159bafd78ae5f6da7213ec 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -159,8 +159,8 @@ module Projects log_message << " Project ID: #{@project.id}" if @project&.id Rails.logger.error(log_message) - if @project - @project.import_state.mark_as_failed(message) if @project.persisted? && @project.import? + if @project && @project.persisted? && @project.import_state + @project.import_state.mark_as_failed(message) end @project diff --git a/db/fixtures/development/02_application_settings.rb b/db/fixtures/development/02_application_settings.rb index d604f0be3cd034b2f2c02c62c5b54bb8344e4f3c..7cdc8e40b69a4037e3fd9b58e0ae8d28862fe026 100644 --- a/db/fixtures/development/02_application_settings.rb +++ b/db/fixtures/development/02_application_settings.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true puts "Creating the default ApplicationSetting record.".color(:green) -Gitlab::CurrentSettings.current_application_settings +ApplicationSetting.create_from_defaults # Details https://gitlab.com/gitlab-org/gitlab-ce/issues/46241 puts "Enable hashed storage for every new projects.".color(:green)