diff options
author | Nick Thomas <nick@gitlab.com> | 2018-12-07 13:55:11 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-12-07 13:55:11 +0000 |
commit | 5c45c21d22c37c2c0922a1f4d699e2549627a5d0 (patch) | |
tree | 871f123605d5d85eced4e78fd275cb5696d66d8e /app/models/shard.rb | |
parent | 9ed1c2b5526eff78b27043f0b73ca0368dd4660f (diff) | |
download | gitlab-ce-5c45c21d22c37c2c0922a1f4d699e2549627a5d0.tar.gz |
Fix transaction pollution in Shard.by_name
Diffstat (limited to 'app/models/shard.rb')
-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 |