I came across Sidekiq best practices docs mentioning that
Just remember that Sidekiq will execute your job at least once, not exactly once.
Can anyone explain what does that mean with examples?
I came across Sidekiq best practices docs mentioning that
Just remember that Sidekiq will execute your job at least once, not exactly once.
Can anyone explain what does that mean with examples?
The explanation of at least once
at the beginning of this paragraph.
For instance, with the error retry functionality, your job might be half-processed, throw an error, and then be re-executed over and over until it successfully completes.
def perform
$counter += 1
raise RuntimeError, 'Run again'
end
As shown above, we raise an error before successfully completes, this job will be retried until the number of tries exhausted. Every time the job runs, $counter
will increase by 1.
Make your job idempotent and transactional to avoid inconsistencies.