diff --git a/lib/gitlab/sidekiq_middleware/monitor.rb b/lib/gitlab/sidekiq_middleware/monitor.rb index 0d88fe760d3..53a6132edac 100644 --- a/lib/gitlab/sidekiq_middleware/monitor.rb +++ b/lib/gitlab/sidekiq_middleware/monitor.rb @@ -8,8 +8,12 @@ module Gitlab yield end rescue Gitlab::SidekiqMonitor::CancelledError + # push job to DeadSet + payload = ::Sidekiq.dump_json(job) + ::Sidekiq::DeadSet.new.kill(payload, notify_failure: false) + # ignore retries - raise Sidekiq::JobRetry::Skip + raise ::Sidekiq::JobRetry::Skip end end end diff --git a/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb b/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb index 2933d26a387..7319cdc2399 100644 --- a/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb @@ -33,9 +33,17 @@ describe Gitlab::SidekiqMiddleware::Monitor do end end - it 'does skip this job' do + it 'skips the job' do expect { subject }.to raise_error(Sidekiq::JobRetry::Skip) end + + it 'puts job in DeadSet' do + ::Sidekiq::DeadSet.new.clear + + expect do + subject rescue Sidekiq::JobRetry::Skip + end.to change { ::Sidekiq::DeadSet.new.size }.by(1) + end end end end