Today I Learned

Clear Sidekiq morgue from duplicate entries

Cleaning up Sidekiq’s Dead queue (Morgue) using WebUI may be really cumbersome, especially if you would like to remove only particular kinds of errors.

Simple script helps here (is also helpful when cleaning up other queues).

Sidekiq::DeadSet.new.each do |item| 
   item.delete if (item['class'] == 'User::DeliverRegistrationNotificationWorker') 
end

There are quite a few interesting attributes you can perform search on. Example below

{"class"=>"User::DeliverRegistrationNotificationWorker",
 "args"=>[22229],
 "retry"=>10,
 "queue"=>"default",
 "backtrace"=>20,
 "dead"=>true,
 "lock"=>"until_executed",
 "on_conflict"=>"log",
 "jid"=>"42e28053e9bd1677af43f338",
 "created_at"=>1574888438.0833654,
 "lock_timeout"=>0,
 "lock_expiration"=>nil,
 "unique_prefix"=>"uniquejobs",
 "unique_args"=>[22229],
 "unique_digest"=>"uniquejobs:fc2a4853c695508d7d6aeed9bef5fcfd",
 "enqueued_at"=>1574889167.5561223,
 "error_message"=>"User::DeliverRegistrationNotification::MessageNotDelivered",
 "error_class"=>"User::DeliverRegistrationNotification::MessageNotDelivered",
 "failed_at"=>1574888691.039675,
 "retry_count"=>10,
 "error_backtrace"=> []
}