Commit 99efa8b0 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '262694-nomethoderror-in-elasticindexbulkcronworker' into 'master'

Do not update Elasticsearch for pending_delete projects

See merge request gitlab-org/gitlab!61917
parents 113610e1 a574bbe0
......@@ -18,6 +18,14 @@ module Elastic
::Elastic::ProcessInitialBookkeepingService.track!(self)
end
override :maintain_elasticsearch_update
def maintain_elasticsearch_update(updated_attributes: previous_changes.keys)
# avoid race condition if project is deleted before Elasticsearch update completes
return if pending_delete?
super
end
override :maintain_elasticsearch_destroy
def maintain_elasticsearch_destroy
ElasticDeleteProjectWorker.perform_async(self.id, self.es_id)
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Project, :elastic do
RSpec.describe Project, :elastic, :clean_gitlab_redis_shared_state do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
......@@ -184,6 +184,17 @@ RSpec.describe Project, :elastic do
expect(described_class.elastic_search('"someone_elses_project"', options: { project_ids: project_ids }).total_count).to eq(0)
end
it 'does not update Elasticsearch if pending_delete is true' do
expect(Elastic::ProcessInitialBookkeepingService).to receive(:track!)
project = create(:project)
expect(Elastic::ProcessBookkeepingService).to receive(:track!)
project.update!(name: 'test 1')
expect(Elastic::ProcessBookkeepingService).not_to receive(:track!)
project.update!(pending_delete: true)
end
it "finds partial matches in project names" do
project_ids = []
......
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