Commit 219a62e3 authored by Dylan Griffith's avatar Dylan Griffith

Remove dead Elasticsearch indexing locking code

The code paths that used to use these locks have been long removed so we
can safely remove them. Additionally these are superceded by better
de-duplication mechanisms including sidekiq queue de-duplication for
`ElasticCommitIndexerWorker`, redis sorted sets for other indexing jobs
and finally we added a lock inside of `ElasticCommitIndexerWorker`
recently to avoid a related problem that these locks didn't even cover
anyway https://gitlab.com/gitlab-org/gitlab/-/merge_requests/35842 .
parent efb5a230
......@@ -566,12 +566,6 @@ Here are some common pitfalls and how to overcome them:
You can run `sudo gitlab-rake gitlab:elastic:projects_not_indexed` to display projects that aren't indexed.
- **No new data is added to the Elasticsearch index when I push code**
When performing the initial indexing of blobs, we lock all projects until the project finishes indexing. It could
happen that an error during the process causes one or multiple projects to remain locked. In order to unlock them,
run the `gitlab:elastic:clear_locked_projects` Rake task.
- **"Can't specify parent if no parent field has been configured"**
If you enabled Elasticsearch before GitLab 8.12 and have not rebuilt indexes you will get
......
......@@ -34,12 +34,8 @@ module EE
def should_index_commits?
return false unless default_branch?
return false unless project.use_elasticsearch?
# Check that we're not already indexing this project
::Gitlab::Redis::SharedState.with do |redis|
!redis.sismember(:elastic_projects_indexing, project.id)
end
project.use_elasticsearch?
end
end
end
......
......@@ -46,13 +46,6 @@ namespace :gitlab do
puts "Indexing is %.2f%% complete (%d/%d projects)" % [percent, indexed, projects]
end
desc 'GitLab | Elasticsearch | Unlock repositories for indexing in case something gets stuck'
task clear_locked_projects: :environment do
Gitlab::Redis::SharedState.with { |redis| redis.del(:elastic_projects_indexing) }
puts 'Cleared all locked projects. Incremental indexing should work now.'
end
desc "GitLab | Elasticsearch | Index all snippets"
task index_snippets: :environment do
logger = Logger.new(STDOUT)
......@@ -127,7 +120,6 @@ namespace :gitlab do
relation.all.in_batches(start: ENV['ID_FROM'], finish: ENV['ID_TO']) do |relation| # rubocop: disable Cop/InBatches
ids = relation.reorder(:id).pluck(:id)
Gitlab::Redis::SharedState.with { |redis| redis.sadd(:elastic_projects_indexing, ids) }
yield ids
end
end
......
......@@ -42,18 +42,6 @@ RSpec.describe Git::BranchPushService do
stub_ee_application_setting(elasticsearch_indexing?: true)
end
context 'when the project is locked by elastic.rake', :clean_gitlab_redis_shared_state do
before do
Gitlab::Redis::SharedState.with { |redis| redis.sadd(:elastic_projects_indexing, project.id) }
end
it 'does not run ElasticCommitIndexerWorker' do
expect(ElasticCommitIndexerWorker).not_to receive(:perform_async)
subject.execute
end
end
it 'runs ElasticCommitIndexerWorker' do
expect(ElasticCommitIndexerWorker).to receive(:perform_async).with(project.id)
......
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