Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
53234295
Commit
53234295
authored
Jul 03, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename retries and remove retry_max
parent
902e69de
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
app/services/concerns/exclusive_lease_lock.rb
app/services/concerns/exclusive_lease_lock.rb
+2
-3
No files found.
app/services/concerns/exclusive_lease_lock.rb
View file @
53234295
...
@@ -3,15 +3,14 @@ module ExclusiveLeaseLock
...
@@ -3,15 +3,14 @@ module ExclusiveLeaseLock
FailedToObtainLockError
=
Class
.
new
(
StandardError
)
FailedToObtainLockError
=
Class
.
new
(
StandardError
)
def
in_lock
(
key
,
ttl:
1
.
minute
,
retr
y_max
:
10
,
sleep_sec:
0.01
.
seconds
)
def
in_lock
(
key
,
ttl:
1
.
minute
,
retr
ies
:
10
,
sleep_sec:
0.01
.
seconds
)
lease
=
Gitlab
::
ExclusiveLease
.
new
(
key
,
timeout:
ttl
)
lease
=
Gitlab
::
ExclusiveLease
.
new
(
key
,
timeout:
ttl
)
retry_count
=
0
until
uuid
=
lease
.
try_obtain
until
uuid
=
lease
.
try_obtain
# Keep trying until we obtain the lease. To prevent hammering Redis too
# Keep trying until we obtain the lease. To prevent hammering Redis too
# much we'll wait for a bit.
# much we'll wait for a bit.
sleep
(
sleep_sec
)
sleep
(
sleep_sec
)
break
if
retry_max
<
(
retry_count
+=
1
)
break
if
(
retries
-=
1
)
<
0
end
end
raise
FailedToObtainLockError
,
'Failed to obtain a lock'
unless
uuid
raise
FailedToObtainLockError
,
'Failed to obtain a lock'
unless
uuid
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment