diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/optimistic_locking.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/gitlab/optimistic_locking.rb b/lib/gitlab/optimistic_locking.rb new file mode 100644 index 00000000000..7668c518bc5 --- /dev/null +++ b/lib/gitlab/optimistic_locking.rb @@ -0,0 +1,13 @@ +module Gitlab + module OptimisticLocking + def retry_lock(subject, &block) + while true do + begin + return yield subject + rescue StaleObjectError + subject.reload + end + end + end + end +end |