mperham/sidekiq — pull request #1805 by sentience (2014-06-27 08:37:45+00:00)
Title: 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. Unfortunately, when a `Sidekiq::Shutdown` is raised during, e.g., an ActiveRecord query, this cause cause another exception (e.g. `ActiveRecord::StatementInvalid`) to be raised, which will trigger Sidekiq to put the job into the Retry queue, in addition to restarting automatically when Sidekiq is next started. In effect, this causes the job to be duplicated.

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.