Commit 26f0ba34 authored by Thong Kuah's avatar Thong Kuah Committed by Vasilii Iakliushin

Revert out eager loading for ExpireJobCacheWorker

parent cf825e60
...@@ -56,7 +56,6 @@ class CommitStatus < Ci::ApplicationRecord ...@@ -56,7 +56,6 @@ class CommitStatus < Ci::ApplicationRecord
scope :for_ref, -> (ref) { where(ref: ref) } scope :for_ref, -> (ref) { where(ref: ref) }
scope :by_name, -> (name) { where(name: name) } scope :by_name, -> (name) { where(name: name) }
scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) } scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) }
scope :eager_load_pipeline, -> { eager_load(:pipeline, project: { namespace: :route }) }
scope :with_pipeline, -> { joins(:pipeline) } scope :with_pipeline, -> { joins(:pipeline) }
scope :updated_at_before, ->(date) { where('ci_builds.updated_at < ?', date) } scope :updated_at_before, ->(date) { where('ci_builds.updated_at < ?', date) }
scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) } scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) }
......
...@@ -18,7 +18,7 @@ class ExpireJobCacheWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -18,7 +18,7 @@ class ExpireJobCacheWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(job_id) def perform(job_id)
job = CommitStatus.eager_load_pipeline.find_by(id: job_id) job = CommitStatus.preload(:pipeline, :project).find_by(id: job_id)
return unless job return unless job
pipeline = job.pipeline pipeline = job.pipeline
......
...@@ -385,7 +385,6 @@ ...@@ -385,7 +385,6 @@
- "./spec/views/projects/jobs/_build.html.haml_spec.rb" - "./spec/views/projects/jobs/_build.html.haml_spec.rb"
- "./spec/workers/ci/drop_pipeline_worker_spec.rb" - "./spec/workers/ci/drop_pipeline_worker_spec.rb"
- "./spec/workers/ci/initial_pipeline_process_worker_spec.rb" - "./spec/workers/ci/initial_pipeline_process_worker_spec.rb"
- "./spec/workers/expire_job_cache_worker_spec.rb"
- "./spec/workers/new_merge_request_worker_spec.rb" - "./spec/workers/new_merge_request_worker_spec.rb"
- "./spec/workers/pipeline_process_worker_spec.rb" - "./spec/workers/pipeline_process_worker_spec.rb"
- "./spec/workers/pipeline_schedule_worker_spec.rb" - "./spec/workers/pipeline_schedule_worker_spec.rb"
......
...@@ -13,24 +13,6 @@ RSpec.describe ExpireJobCacheWorker do ...@@ -13,24 +13,6 @@ RSpec.describe ExpireJobCacheWorker do
let(:job_args) { job.id } let(:job_args) { job.id }
it 'does not perform extra queries', :aggregate_failures do
worker = described_class.new
recorder = ActiveRecord::QueryRecorder.new { worker.perform(job.id) }
occurences = recorder.data.values.flat_map {|v| v[:occurrences]}
project_queries = occurences.select {|s| s.include?('FROM "projects"')}
namespace_queries = occurences.select {|s| s.include?('FROM "namespaces"')}
route_queries = occurences.select {|s| s.include?('FROM "routes"')}
# This worker is run 1 million times an hour, so we need to save as much
# queries as possible.
expect(recorder.count).to be <= 1
expect(project_queries.size).to eq(0)
expect(namespace_queries.size).to eq(0)
expect(route_queries.size).to eq(0)
end
it_behaves_like 'worker with data consistency', it_behaves_like 'worker with data consistency',
described_class, described_class,
data_consistency: :delayed data_consistency: :delayed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment