Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-10-01 07:10:30 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2018-10-02 18:08:13 +0300
commit70d015d1ba5adde82c6f38567ad51cfb85dae5f6 (patch)
tree78793de34c7ca0bb5688db8afd34f9b0a164e29e /app/workers/stuck_ci_jobs_worker.rb
parenta220e72c7027ecf48da73daf0d2de5315b4bc675 (diff)
Cleanup drop_stale_scheduled_builds code
Diffstat (limited to 'app/workers/stuck_ci_jobs_worker.rb')
-rw-r--r--app/workers/stuck_ci_jobs_worker.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb
index 821ea75703f..5028965862f 100644
--- a/app/workers/stuck_ci_jobs_worker.rb
+++ b/app/workers/stuck_ci_jobs_worker.rb
@@ -10,6 +10,7 @@ class StuckCiJobsWorker
BUILD_PENDING_OUTDATED_TIMEOUT = 1.day
BUILD_SCHEDULED_OUTDATED_TIMEOUT = 1.hour
BUILD_PENDING_STUCK_TIMEOUT = 1.hour
+ BUILD_SCHEDULED_OUTDATED_BATCH_SIZE = 100
def perform
return unless try_obtain_lease
@@ -68,8 +69,12 @@ class StuckCiJobsWorker
# `ci_builds` table has a partial index on `id` with `scheduled_at <> NULL` condition.
# Therefore this query's first step uses Index Search, and the following expensive
# filter `scheduled_at < ?` will only perform on a small subset (max: 100 rows)
- Ci::Build.include(EachBatch).where('scheduled_at IS NOT NULL').each_batch(of: 100) do |relation|
- relation.where('scheduled_at < ?', BUILD_SCHEDULED_OUTDATED_TIMEOUT.ago).find_each do |build|
+ Ci::Build.include(EachBatch)
+ .where('scheduled_at IS NOT NULL')
+ .each_batch(of: BUILD_SCHEDULED_OUTDATED_BATCH_SIZE) do |relation|
+ relation
+ .where('scheduled_at < ?', BUILD_SCHEDULED_OUTDATED_TIMEOUT.ago)
+ .find_each(batch_size: BUILD_SCHEDULED_OUTDATED_BATCH_SIZE) do |build|
drop_build(:outdated, build, :scheduled, BUILD_SCHEDULED_OUTDATED_TIMEOUT, :schedule_expired)
end
end