1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
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