Files
gitlabhq/lib/gitlab/optimistic_locking.rb
2016-10-26 11:37:23 +02:00

16 lines
306 B
Ruby

module Gitlab
class OptimisticLocking
def self.retry_lock(subject, &block)
loop do
begin
subject.transaction do
return block.call(subject)
end
rescue ActiveRecord::StaleObjectError
subject.reload
end
end
end
end
end