Fix transaction pollution in Shard.by_name

parent 9ed1c2b5
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment