Commit 44cc8d9f authored by Jarka Košanová's avatar Jarka Košanová

Merge branch 'decomposition_expire_pipeline_worker' into 'master'

Revert out eager loading for ExpirePipelineCacheWorker

See merge request gitlab-org/gitlab!69519
parents d4121fbf d5aa97ab
...@@ -319,7 +319,6 @@ module Ci ...@@ -319,7 +319,6 @@ module Ci
scope :created_after, -> (time) { where('ci_pipelines.created_at > ?', time) } scope :created_after, -> (time) { where('ci_pipelines.created_at > ?', time) }
scope :created_before_id, -> (id) { where('ci_pipelines.id < ?', id) } scope :created_before_id, -> (id) { where('ci_pipelines.id < ?', id) }
scope :before_pipeline, -> (pipeline) { created_before_id(pipeline.id).outside_pipeline_family(pipeline) } scope :before_pipeline, -> (pipeline) { created_before_id(pipeline.id).outside_pipeline_family(pipeline) }
scope :eager_load_project, -> { eager_load(project: [:route, { namespace: :route }]) }
scope :with_pipeline_source, -> (source) { where(source: source)} scope :with_pipeline_source, -> (source) { where(source: source)}
scope :outside_pipeline_family, ->(pipeline) do scope :outside_pipeline_family, ->(pipeline) do
......
...@@ -19,7 +19,7 @@ class ExpirePipelineCacheWorker ...@@ -19,7 +19,7 @@ class ExpirePipelineCacheWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id) def perform(pipeline_id)
pipeline = Ci::Pipeline.eager_load_project.find_by(id: pipeline_id) pipeline = Ci::Pipeline.find_by(id: pipeline_id)
return unless pipeline return unless pipeline
Ci::ExpirePipelineCacheService.new.execute(pipeline) Ci::ExpirePipelineCacheService.new.execute(pipeline)
......
...@@ -386,7 +386,6 @@ ...@@ -386,7 +386,6 @@
- "./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/expire_job_cache_worker_spec.rb"
- "./spec/workers/expire_pipeline_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"
......
...@@ -18,23 +18,6 @@ RSpec.describe ExpirePipelineCacheWorker do ...@@ -18,23 +18,6 @@ RSpec.describe ExpirePipelineCacheWorker do
subject.perform(pipeline.id) subject.perform(pipeline.id)
end end
it 'does not perform extra queries', :aggregate_failures do
recorder = ActiveRecord::QueryRecorder.new { subject.perform(pipeline.id) }
project_queries = recorder.data.values.flat_map {|v| v[:occurrences]}.select {|s| s.include?('FROM "projects"')}
namespace_queries = recorder.data.values.flat_map {|v| v[:occurrences]}.select {|s| s.include?('FROM "namespaces"')}
route_queries = recorder.data.values.flat_map {|v| v[:occurrences]}.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 <= 6
# These arises from #update_etag_cache
expect(project_queries.size).to eq(1)
expect(namespace_queries.size).to eq(1)
expect(route_queries.size).to eq(1)
end
it "doesn't do anything if the pipeline not exist" do it "doesn't do anything if the pipeline not exist" do
expect_any_instance_of(Ci::ExpirePipelineCacheService).not_to receive(:execute) expect_any_instance_of(Ci::ExpirePipelineCacheService).not_to receive(:execute)
expect_any_instance_of(Gitlab::EtagCaching::Store).not_to receive(:touch) expect_any_instance_of(Gitlab::EtagCaching::Store).not_to receive(:touch)
......
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