Commit 12390a2e authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Merge branch 'revert_eager_load_expire_job_worker' into 'master'

Revert out eager loading for ExpireJobCacheWorker

See merge request gitlab-org/gitlab!69605
parents 8c965c97 26f0ba34
......@@ -56,7 +56,6 @@ class CommitStatus < Ci::ApplicationRecord
scope :for_ref, -> (ref) { where(ref: ref) }
scope :by_name, -> (name) { where(name: name) }
scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) }
scope :eager_load_pipeline, -> { eager_load(:pipeline, project: { namespace: :route }) }
scope :with_pipeline, -> { joins(:pipeline) }
scope :updated_at_before, ->(date) { where('ci_builds.updated_at < ?', date) }
scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) }
......
......@@ -18,7 +18,7 @@ class ExpireJobCacheWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: disable CodeReuse/ActiveRecord
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
pipeline = job.pipeline
......
......@@ -381,7 +381,6 @@
- "./spec/views/projects/jobs/_build.html.haml_spec.rb"
- "./spec/workers/ci/drop_pipeline_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/pipeline_process_worker_spec.rb"
- "./spec/workers/pipeline_schedule_worker_spec.rb"
......
......@@ -13,24 +13,6 @@ RSpec.describe ExpireJobCacheWorker do
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',
described_class,
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