Sidekiq Retry Count in Job

Retry Sidekiq worker from within worker

If you do not want to have nested workers, then in MailingWorker instead of enqueuing it again, raise an exception if the PDF is not present.
Also, configure the worker retry option, so that sidekiq will push it to the retry queue and run it again in sometime. According to the documentation,

Sidekiq will retry failures with an exponential backoff using the 
formula (retry_count ** 4) + 15 + (rand(30) * (retry_count + 1)) (i.e.
15, 16, 31, 96, 271, ... seconds + a random amount of time). It will
perform 25 retries over approximately 21 days.

Worker code will be more like,

class MailingWorker
include Sidekiq::Worker
sidekiq_options retry: 5

def perform(d_id,model)

@d = eval(model).find(d_id)
@model = model
if @d.pdf.present?
ProfessionnelMailer.notification_d(@d).deliver
ClientMailer.notification_d(@d).deliver
else
raise "PDF not present"
end
end
end

Sidekiq: change rate of retry for failed job?

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

How to get sidekiq retry_count from inside a job

There is no way to get the retry count from within the job, by design.

How to mark a sidekiq task/job for retry without raising an error?

You raise a specific error and tell the error service to ignore errors of that type. For NewRelic:

https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration#error_collector.ignore_errors

How do I get a sidekiq retry job from re-appearing in the dashboard?

There are two entries in the Retries because they are two different jobs. You can create "identical" jobs (with the same class and arguments) that differ only in their internal Job ID.

How to set a global retry limit in sidekiq?

Sidekiq.default_worker_options['retry'] = 10

https://github.com/mperham/sidekiq/wiki/Advanced-Options#workers



Related Topics



Leave a reply



Submit