diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-12-12 16:17:45 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-12-12 16:17:45 +0900 |
commit | 3494cdfecb7748cca558e46c805b636b3383c299 (patch) | |
tree | 49b89ffd6b2fdc9af393492147d9c99f4aca7edf /app/services | |
parent | 8d739237de2d1bcfa063be422eac71c0566a4a54 (diff) | |
download | gitlab-ce-3494cdfecb7748cca558e46c805b636b3383c299.tar.gz |
ActiveRecord::StaleObjectError: Attempted to update a stale object: Ci::Build41023-activerecord-staleobjecterror--attempted-to-update-a-stale-object--ci-build
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/ci/register_job_service.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index c8b6450c9b5..f832b79ef21 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -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. - build.runner_id = runner.id - build.run! - register_success(build) - - return Result.new(build, true) + 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 |