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:
authorNick Thomas <nick@gitlab.com>2018-11-13 23:41:45 +0300
committerNick Thomas <nick@gitlab.com>2018-11-13 23:43:33 +0300
commit3d1690c77625fbbfa5c0ec28aeabc9702c5dfb05 (patch)
treee299d2847fca543a7b4669068b52a501d8b009ee /app/models/shard.rb
parent132e6c9f95a7a2d3aa7f78072b18c331128f8065 (diff)
Fix a race condition intermittently breaking GitLab startup
Diffstat (limited to 'app/models/shard.rb')
-rw-r--r--app/models/shard.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/app/models/shard.rb b/app/models/shard.rb
index 2fa22bd040c..2e75bc91df0 100644
--- a/app/models/shard.rb
+++ b/app/models/shard.rb
@@ -9,13 +9,12 @@ class Shard < ActiveRecord::Base
# The GitLab config does not change for the lifecycle of the process
in_config = Gitlab.config.repositories.storages.keys.map(&:to_s)
+ in_db = all.pluck(:name)
- transaction do
- in_db = all.pluck(:name)
- missing = in_config - in_db
-
- missing.map { |name| by_name(name) }
- end
+ # This may race with other processes creating shards at the same time, but
+ # `by_name` will handle that correctly
+ missing = in_config - in_db
+ missing.map { |name| by_name(name) }
end
def self.by_name(name)