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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
c588dd84
Commit
c588dd84
authored
Apr 26, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ExclusiveLease for trace write locking
parent
9d6fe7bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
app/models/ci/build_trace_chunk.rb
app/models/ci/build_trace_chunk.rb
+7
-7
No files found.
app/models/ci/build_trace_chunk.rb
View file @
c588dd84
...
@@ -12,9 +12,9 @@ module Ci
...
@@ -12,9 +12,9 @@ module Ci
CHUNK_SIZE
=
128
.
kilobytes
CHUNK_SIZE
=
128
.
kilobytes
CHUNK_REDIS_TTL
=
1
.
week
CHUNK_REDIS_TTL
=
1
.
week
LOCK_RETRY
=
100
WRITE_
LOCK_RETRY
=
100
LOCK_SLEEP
=
1
WRITE_
LOCK_SLEEP
=
1
LOCK_TTL
=
5
.
minutes
WRITE_
LOCK_TTL
=
5
.
minutes
enum
data_store:
{
enum
data_store:
{
redis:
1
,
redis:
1
,
...
@@ -122,18 +122,18 @@ module Ci
...
@@ -122,18 +122,18 @@ module Ci
end
end
def
redis_lock_key
def
redis_lock_key
"
gitlab:ci:trace:
#{
build_id
}
:chunks:
#{
chunk_index
}
:lock
"
"
trace_write:
#{
build_id
}
:chunks:
#{
chunk_index
}
"
end
end
def
in_lock
def
in_lock
lease
=
Gitlab
::
ExclusiveLease
.
new
(
redis_lock_key
,
timeout:
LOCK_TTL
)
lease
=
Gitlab
::
ExclusiveLease
.
new
(
redis_lock_key
,
timeout:
WRITE_
LOCK_TTL
)
retry_count
=
0
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 between retries.
# much we'll wait for a bit between retries.
sleep
(
LOCK_SLEEP
)
sleep
(
WRITE_
LOCK_SLEEP
)
break
if
LOCK_RETRY
<
(
retry_count
+=
1
)
break
if
WRITE_
LOCK_RETRY
<
(
retry_count
+=
1
)
end
end
raise
WriteError
,
'Failed to obtain write lock'
unless
uuid
raise
WriteError
,
'Failed to obtain write 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