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
2822526e
Commit
2822526e
authored
Oct 27, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make retry_lock to not be infinite
parent
39c17ccb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
app/services/ci/process_pipeline_service.rb
app/services/ci/process_pipeline_service.rb
+2
-2
lib/gitlab/optimistic_locking.rb
lib/gitlab/optimistic_locking.rb
+7
-3
spec/lib/gitlab/optimistic_locking_spec.rb
spec/lib/gitlab/optimistic_locking_spec.rb
+11
-0
No files found.
app/services/ci/process_pipeline_service.rb
View file @
2822526e
...
...
@@ -31,8 +31,8 @@ module Ci
if
HasStatus
::
COMPLETED_STATUSES
.
include?
(
current_status
)
created_builds_in_stage
(
index
).
select
do
|
build
|
Gitlab
::
OptimisticLocking
.
retry_lock
(
build
)
do
|
build
|
process_build
(
build
,
current_status
)
Gitlab
::
OptimisticLocking
.
retry_lock
(
build
)
do
|
subject
|
process_build
(
subject
,
current_status
)
end
end
end
...
...
lib/gitlab/optimistic_locking.rb
View file @
2822526e
module
Gitlab
class
OptimisticLocking
def
self
.
retry_lock
(
subject
,
&
block
)
module
OptimisticLocking
extend
self
def
retry_lock
(
subject
,
retries
=
100
,
&
block
)
loop
do
begin
subject
.
transaction
do
ActiveRecord
::
Base
.
transaction
do
return
block
.
call
(
subject
)
end
rescue
ActiveRecord
::
StaleObjectError
retries
-=
1
raise
unless
retries
>=
0
subject
.
reload
end
end
...
...
spec/lib/gitlab/optimistic_locking_spec.rb
View file @
2822526e
...
...
@@ -24,5 +24,16 @@ describe Gitlab::OptimisticLocking, lib: true do
subject
.
drop
end
end
it
'raises exception when too many retries'
do
expect
(
pipeline
).
to
receive
(
:drop
).
twice
.
and_call_original
expect
do
described_class
.
retry_lock
(
pipeline
,
1
)
do
|
subject
|
subject
.
lock_version
=
100
subject
.
drop
end
end
.
to
raise_error
(
ActiveRecord
::
StaleObjectError
)
end
end
end
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