I have jobs of a particular type that I'd like to have retry more frequently than set by the default Sidekiq interval. Is this currently possible? Ideally the job would retry every 5 seconds for up to a minute. Not entirely sure this is currently something that's trivial to plugin to a Sidekiq job.
Asked
Active
Viewed 1.6k times
3 Answers
33
According to: https://github.com/mperham/sidekiq/wiki/Error-Handling you can do this:
class Worker
include Sidekiq::Worker
sidekiq_retry_in do |count|
5
end
end

Bart
- 2,606
- 21
- 32
-
7Please notice that `5` is counted in seconds – Neodelf Mar 30 '17 at 08:12
1
If you need other range, can use minute syntax
sidekiq_retry_in do |_count|
10.minutes
end

CHBLU
- 11
- 2
-
This will work in sidekiq 5 and 7 but not 6 as per https://github.com/sidekiq/sidekiq/issues/5806 – RMK Feb 27 '23 at 15:08
-
1
I'm answering if calling 10.minutes
in the block works, because I can't comment on an answer.
According to the Sidekiq code, you need to pass an Integer, or either :kill
or :discard
symbols.
10.minutes
returns an instance of ActiveSupport::Duration
This means that the following would work:
class Worker
include Sidekiq::Worker
sidekiq_retry_in { 10.minutes.to_i }
end

antonpot
- 41
- 9
-
In sidekiq 7 this has been fixed (https://github.com/sidekiq/sidekiq/issues/5806), durations should now work as before – RMK Feb 27 '23 at 15:09