diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-20 10:33:44 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-26 12:37:23 +0300 |
commit | 5d7ee7a1b6c818dd0ccba6a393875072dabd7eba (patch) | |
tree | 80067ea849e46a106e3177de7bcba050748c164b /lib | |
parent | 198ae21e2ccd88f2670faf90d69799f2b3294b73 (diff) |
Use optimistic locking
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 |