Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2019-08-01 17:58:14 +0300
committerDouwe Maan <douwe@gitlab.com>2019-08-01 17:58:14 +0300
commitc017dc578dc78729050792d22b449ce0529479cf (patch)
tree4ed307f81cf1f6468413e31b22e04f6388f7301f /lib/gitlab
parent354cd090521984dc95ce2ee2713b81a82aec2577 (diff)
parentf4cd926cf3eec069396ab995b3553f40617c19e6 (diff)
Merge branch 'osw-avoid-errors-due-to-concurrent-calls' into 'master'
Add exclusive lease to mergeability check process See merge request gitlab-org/gitlab-ce!31082
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/exclusive_lease_helpers.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/gitlab/exclusive_lease_helpers.rb b/lib/gitlab/exclusive_lease_helpers.rb
index 7961d4bbd6e..61eb030563d 100644
--- a/lib/gitlab/exclusive_lease_helpers.rb
+++ b/lib/gitlab/exclusive_lease_helpers.rb
@@ -15,17 +15,18 @@ module Gitlab
raise ArgumentError, 'Key needs to be specified' unless key
lease = Gitlab::ExclusiveLease.new(key, timeout: ttl)
+ retried = false
until uuid = lease.try_obtain
# Keep trying until we obtain the lease. To prevent hammering Redis too
# much we'll wait for a bit.
sleep(sleep_sec)
- break if (retries -= 1) < 0
+ (retries -= 1) < 0 ? break : retried ||= true
end
raise FailedToObtainLockError, 'Failed to obtain a lock' unless uuid
- yield
+ yield(retried)
ensure
Gitlab::ExclusiveLease.cancel(key, uuid)
end