3

I am looking for a way to track sidekiq jobs that have been killed abruptly. Is there a on_delete kind of operation in sidekiq(I couldnt find any in documentation) I can implement, so that some process is carried out whenever a job gets deleted abruptly.

I looked into sidekiq ruby gem documentation, but couldnt find a solution for this.

I am using sidekiq v5.0.4

krishna sai
  • 185
  • 8
  • When you say "killed abruptly" how are those jobs being killed? Sidekiq jobs can be set to retry n number of times in case they fail for some reason i.e. 3rd part API is down, internet connection down etc. If you expect this to happen you should set a retry number of 3 for example. What do you want to do if the job fails even 3 retries for example? – lacostenycoder Jun 18 '19 at 11:17
  • through console and jib, they are being deleted, these might be scheduled jobs, so they might not have even been started. So, they wont be moved to failed queue. I think I am looking to send a notification of sort whenever a developer deletes a scheduled job. Does this make sense?\ – krishna sai Jun 18 '19 at 11:43
  • how and why are devs deleting jobs? this seems like a bad workflow – lacostenycoder Jun 18 '19 at 11:50
  • I am not really sure on why, but it happens rarely. Is there a way I can add something so that a notification gets sent out whenever a sidekiq job gets cancelled. – krishna sai Jun 18 '19 at 12:05
  • see the answer I posted below – lacostenycoder Jun 18 '19 at 12:32

1 Answers1

1

Sidekiq jobs which die because of some exception should be retried by using the retry setting

class SomeWorker
  include Sidekiq::Worker

  sidekiq_options retry: 3 # retry 3 times before dying 

  def perform
    # do stuff
  end
end

Jobs which die after all retries end up in the dead queue

There is no easy way to monitor jobs that are deleted from the Sidekiq queues because of devs removing them in the console or deleting them. Once they are deleted there's nothing to hook into anymore as they will be removed from the key/value store i.e. Redis.

If you want to monitor specific job statuses you might want to have a look at the sidekiq-status gem which can help with this.

lacostenycoder
  • 10,623
  • 4
  • 31
  • 48