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
Jérome Perrin
gitlab-ce
Commits
3494cdfe
Commit
3494cdfe
authored
Dec 12, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ActiveRecord::StaleObjectError: Attempted to update a stale object: Ci::Build
parent
8d739237
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+9
-8
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+13
-0
No files found.
app/services/ci/register_job_service.rb
View file @
3494cdfe
...
...
@@ -38,11 +38,15 @@ module Ci
begin
# In case when 2 runners try to assign the same build, second runner will be declined
# with StateMachines::InvalidTransition or StaleObjectError when doing run! or save method.
begin
build
.
runner_id
=
runner
.
id
build
.
run!
register_success
(
build
)
return
Result
.
new
(
build
,
true
)
rescue
Ci
::
Build
::
MissingDependenciesError
build
.
drop!
(
:missing_dependency_failure
)
end
rescue
StateMachines
::
InvalidTransition
,
ActiveRecord
::
StaleObjectError
# We are looping to find another build that is not conflicting
# It also indicates that this build can be picked and passed to runner.
...
...
@@ -54,9 +58,6 @@ module Ci
# we still have to return 409 in the end,
# to make sure that this is properly handled by runner.
valid
=
false
rescue
Ci
::
Build
::
MissingDependenciesError
build
.
drop!
(
:missing_dependency_failure
)
valid
=
false
end
end
...
...
spec/services/ci/register_job_service_spec.rb
View file @
3494cdfe
...
...
@@ -307,6 +307,19 @@ module Ci
it_behaves_like
'not pick'
end
context
'when job object is staled'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
before
do
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:drop!
)
.
and_raise
(
ActiveRecord
::
StaleObjectError
.
new
(
pending_job
,
:drop!
))
end
it
'does not drop nor pick'
do
expect
(
subject
).
to
be_nil
end
end
end
shared_examples
'validation is not active'
do
...
...
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