summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-12 10:17:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-12 10:17:34 +0000
commit3a6238c2e23454c462ccd229b1802583e657bfd0 (patch)
tree808c1151b9916516e41cea4869791cbf3dab345f /app
parentc301cf0ca5fbb998c22be5d8033e77be4bf0a451 (diff)
downloadgitlab-ce-3a6238c2e23454c462ccd229b1802583e657bfd0.tar.gz
Add latest changes from gitlab-org/gitlab@14-9-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/services/ci/register_job_service.rb12
-rw-r--r--app/services/ci/update_build_queue_service.rb17
2 files changed, 23 insertions, 6 deletions
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb
index 59c4c17a964..c8b475f6c48 100644
--- a/app/services/ci/register_job_service.rb
+++ b/app/services/ci/register_job_service.rb
@@ -156,6 +156,18 @@ module Ci
def process_build(build, params)
unless build.pending?
@metrics.increment_queue_operation(:build_not_pending)
+
+ if Feature.enabled?(:ci_pending_builds_table_resiliency, default_enabled: :yaml)
+ ##
+ # If this build can not be picked because we had stale data in
+ # `ci_pending_builds` table, we need to respond with 409 to retry
+ # this operation.
+ #
+ if ::Ci::UpdateBuildQueueService.new.remove!(build)
+ return Result.new(nil, nil, false)
+ end
+ end
+
return
end
diff --git a/app/services/ci/update_build_queue_service.rb b/app/services/ci/update_build_queue_service.rb
index 5a011a8cac6..a525ea179e0 100644
--- a/app/services/ci/update_build_queue_service.rb
+++ b/app/services/ci/update_build_queue_service.rb
@@ -37,14 +37,19 @@ module Ci
raise InvalidQueueTransition unless transition.from == 'pending'
- transition.within_transaction do
- removed = build.all_queuing_entries.delete_all
+ transition.within_transaction { remove!(build) }
+ end
- if removed > 0
- metrics.increment_queue_operation(:build_queue_pop)
+ ##
+ # Force recemove build from the queue, without checking a transition state
+ #
+ def remove!(build)
+ removed = build.all_queuing_entries.delete_all
- build.id
- end
+ if removed > 0
+ metrics.increment_queue_operation(:build_queue_pop)
+
+ build.id
end
end