Commit ce36b109 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ee-1979-1-3-fix-approvals-required' into 'master'

Consume jobs from dead and retry queues

See merge request gitlab-org/gitlab-ce!24881
parents 4f9551b8 c34f6ea6
...@@ -16,11 +16,18 @@ module Gitlab ...@@ -16,11 +16,18 @@ module Gitlab
# re-raises the exception. # re-raises the exception.
# #
# steal_class - The name of the class for which to steal jobs. # steal_class - The name of the class for which to steal jobs.
def self.steal(steal_class) def self.steal(steal_class, retry_dead_jobs: false)
enqueued = Sidekiq::Queue.new(self.queue) queues = [
scheduled = Sidekiq::ScheduledSet.new Sidekiq::ScheduledSet.new,
Sidekiq::Queue.new(self.queue)
]
if retry_dead_jobs
queues << Sidekiq::RetrySet.new
queues << Sidekiq::DeadSet.new
end
[scheduled, enqueued].each do |queue| queues.each do |queue|
queue.each do |job| queue.each do |job|
migration_class, migration_args = job.args migration_class, migration_args = job.args
......
...@@ -104,6 +104,38 @@ describe Gitlab::BackgroundMigration do ...@@ -104,6 +104,38 @@ describe Gitlab::BackgroundMigration do
end end
end end
end end
context 'when retry_dead_jobs is true', :sidekiq, :redis do
let(:retry_queue) do
[double(args: ['Object', [3]], queue: described_class.queue, delete: true)]
end
let(:dead_queue) do
[double(args: ['Object', [4]], queue: described_class.queue, delete: true)]
end
before do
allow(Sidekiq::RetrySet).to receive(:new).and_return(retry_queue)
allow(Sidekiq::DeadSet).to receive(:new).and_return(dead_queue)
end
it 'steals from the dead and retry queue' do
Sidekiq::Testing.disable! do
expect(described_class).to receive(:perform)
.with('Object', [1]).ordered
expect(described_class).to receive(:perform)
.with('Object', [2]).ordered
expect(described_class).to receive(:perform)
.with('Object', [3]).ordered
expect(described_class).to receive(:perform)
.with('Object', [4]).ordered
BackgroundMigrationWorker.perform_async('Object', [2])
BackgroundMigrationWorker.perform_in(10.minutes, 'Object', [1])
described_class.steal('Object', retry_dead_jobs: true)
end
end
end
end end
describe '.perform' do describe '.perform' do
......
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