Implement Sidekiq pause control middleware
What does this MR do and why?
This MR implements pause control middleware to be able to pause Sidekiq workers conditionally. Paused jobs will be stored in a separate ZSET until the pause strategy becomes inactive. When that happens, PauseControlWorker
puts the jobs back into the queues.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Launch
gdk tail -f rails-background-jobs
in a terminal window - Execute
Zoekt::IndexerWorker.perform_async(7)
- Ensure that the job was processed with
"job_status":"done"
- Run
::Feature.enable(:zoekt_pause_indexing)
- Execute
Zoekt::IndexerWorker.perform_async(7)
once again - Ensure that it returns nil
- Ensure that
Gitlab::SidekiqMiddleware::PauseControl::PauseControlService.queue_size('Zoekt::IndexerWorker')
returns1
- Run
::Feature.disable(:zoekt_pause_indexing)
- After running
PauseControl::ResumeWorker.new.perform
you should see that the paused job was processed
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #389754 (closed)
Edited by Dmitry Gruzd