Commit 88d56756 authored by Dylan Griffith's avatar Dylan Griffith

Update lock timeout in ElasticCommitIndexerWorker

This lock prevents indexing the same project twice in parallel which is
a big problem. The lock will clear itself when the job finishes but you
need a timeout since the lock lives in Redis and the process may crash
before it can clear the lock.

We chose 1 hour originally since we assumed this was enough time to
finish indexing any project but we've found from several customer
tickets https://gitlab.com/gitlab-org/gitlab/-/issues/323856 that some
very large projects are taking longer than an hour to finish indexing.
Increasing this to 1 day probably will dramatically reduce the risk of 2
projects indexing at the same time while still providing a reasonable
timeout in the rare event the process crashes and can't clean up the
lock.

Changelog: fixed
parent 9829525f
......@@ -25,7 +25,7 @@ class ElasticCommitIndexerWorker
project = Project.find(project_id)
return true unless project.use_elasticsearch?
in_lock("#{self.class.name}/#{project_id}/#{wiki}", ttl: 1.hour, retries: 0) do
in_lock("#{self.class.name}/#{project_id}/#{wiki}", ttl: 1.day, retries: 0) do
Gitlab::Elastic::Indexer.new(project, wiki: wiki).run
end
end
......
---
title: Update lock timeout in ElasticCommitIndexerWorker
merge_request: 60768
author:
type: fixed
......@@ -37,7 +37,7 @@ RSpec.describe ElasticCommitIndexerWorker do
it 'does not run index when it is locked' do
expect(subject).to receive(:in_lock) # Mock and don't yield
.with("ElasticCommitIndexerWorker/#{project.id}/false", ttl: 1.hour, retries: 0)
.with("ElasticCommitIndexerWorker/#{project.id}/false", ttl: 1.day, retries: 0)
expect(Gitlab::Elastic::Indexer).not_to receive(:new)
......
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