summaryrefslogtreecommitdiff
path: root/spec/workers/repository_check/batch_worker_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-06 09:05:58 -0700
committerStan Hu <stanhu@gmail.com>2018-07-06 10:11:59 -0700
commitb33661d6ec8498ae1dadfb3b2be0e4a80e61f108 (patch)
treed6b80c77965177619a6f4d149a10b613815fbfe6 /spec/workers/repository_check/batch_worker_spec.rb
parenta291bcdf0d3ed892dcb805e11a43afcadbc20e8b (diff)
downloadgitlab-ce-b33661d6ec8498ae1dadfb3b2be0e4a80e61f108.tar.gz
Add ExclusiveLease guards for RepositoryCheck::{DispatchWorker,BatchWorker}
We saw in production that DispatchWorker was running about twice an hour, which would schedule twice as many jobs as it should. For some reason, BatchWorker was running 1000 times per hour, possibly due to Sidekiq RSS kills that caused these jobs to restart. Adding an ExclusiveLease prevents these jobs from running more than they should. Relates to https://gitlab.com/gitlab-com/infrastructure/issues/4526
Diffstat (limited to 'spec/workers/repository_check/batch_worker_spec.rb')
-rw-r--r--spec/workers/repository_check/batch_worker_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/workers/repository_check/batch_worker_spec.rb b/spec/workers/repository_check/batch_worker_spec.rb
index 6bc551be9ad..ede271b2cdd 100644
--- a/spec/workers/repository_check/batch_worker_spec.rb
+++ b/spec/workers/repository_check/batch_worker_spec.rb
@@ -62,4 +62,12 @@ describe RepositoryCheck::BatchWorker do
expect(subject.perform(shard_name)).to eq([])
end
+
+ it 'does not run if the exclusive lease is taken' do
+ allow(subject).to receive(:try_obtain_lease).and_return(false)
+
+ expect(subject).not_to receive(:perform_repository_checks)
+
+ subject.perform(shard_name)
+ end
end