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:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-11-21 20:44:52 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-11-27 13:56:15 +0300
commita26e25ea757f475afa1b6fd667c58fe15e306022 (patch)
tree8cfe4171f30c7080b9083f2c49e21dab5522f30c /app/workers/stuck_ci_jobs_worker.rb
parent03b891c5791f17bbe426a47f53e0f46704543182 (diff)
Optimise StuckCiJobsWorker
Diffstat (limited to 'app/workers/stuck_ci_jobs_worker.rb')
-rw-r--r--app/workers/stuck_ci_jobs_worker.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb
index fdbc049c2df..566b4507965 100644
--- a/app/workers/stuck_ci_jobs_worker.rb
+++ b/app/workers/stuck_ci_jobs_worker.rb
@@ -45,9 +45,13 @@ class StuckCiJobsWorker
end
def search(status, timeout)
- builds = Ci::Build.where(status: status).where('ci_builds.updated_at < ?', timeout.ago)
- builds.joins(:project).merge(Project.without_deleted).includes(:tags, :runner, project: :namespace).find_each(batch_size: 50).each do |build|
- yield(build)
+ Ci::Build.where(status: status).in_batches(of: 1000) do |batch|
+ batch = batch.where('ci_builds.updated_at < ?', timeout.ago)
+ .joins(:project).merge(Project.without_deleted)
+ .includes(:tags, :runner, project: :namespace)
+ batch.each do |build|
+ yield(build)
+ end
end
end
@@ -58,3 +62,4 @@ class StuckCiJobsWorker
end
end
end
+