mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Prevent exceptions caused by Sidekiq::Shutdown from causing jobs to be retried.
Jobs in progress during a Sidekiq shutdown/restart are requeued for immediate execution. They should not also be queued for retry. This is an attempt at a cleaner fix than that proposed with mperham#1354, also discussed on mperham#897. Because it depends on Exception#cause, this fix will only be effective on Ruby 2.1.0; however, the code will run on earlier Rubies.
This commit is contained in:
parent
a53c884c2e
commit
56b55845d8
1 changed files with 6 additions and 0 deletions
|
@ -64,6 +64,12 @@ module Sidekiq
|
|||
# ignore, will be pushed back onto queue during hard_shutdown
|
||||
raise
|
||||
rescue Exception => e
|
||||
# In Ruby 2.1.0 only, check if exception is a result of shutdown.
|
||||
# If so, will be pushed back onto queue during hard_shutdown.
|
||||
if defined?(e.cause) && e.cause.class == Sidekiq::Shutdown
|
||||
raise Sidekiq::Shutdown
|
||||
end
|
||||
|
||||
raise e unless msg['retry']
|
||||
max_retry_attempts = retry_attempts_from(msg['retry'], @max_retries)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue