diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-12-07 17:41:57 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-12-07 17:41:57 +0300 |
commit | 6173727a36dfe4ea99f8e2794d0280d515ddbb53 (patch) | |
tree | 127f00c642439a1316dc55cc96caea8635484be2 /app | |
parent | 005c4effd04b03b91b25490af25b2da559a4ada7 (diff) | |
parent | 5c45c21d22c37c2c0922a1f4d699e2549627a5d0 (diff) |
Merge branch 'fix-transaction-shard' into 'master'
Fix transaction pollution in Shard.by_name
See merge request gitlab-org/gitlab-ce!23655
Diffstat (limited to 'app')
-rw-r--r-- | app/models/shard.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/shard.rb b/app/models/shard.rb index 2e75bc91df0..e39d4232486 100644 --- a/app/models/shard.rb +++ b/app/models/shard.rb @@ -18,7 +18,9 @@ class Shard < ActiveRecord::Base end def self.by_name(name) - find_or_create_by(name: name) + transaction(requires_new: true) do + find_or_create_by(name: name) + end rescue ActiveRecord::RecordNotUnique retry end |