bull icon indicating copy to clipboard operation
bull copied to clipboard

How many times is a job retried based on the attempts we declare when adding a job in queue?

Open sanyaldips93 opened this issue 2 years ago • 3 comments

Hi

I have experimenting with the 'attempts' option while adding a job to a queue for sometime now. As per my understanding from bull documentation, the job is retried as many times as declared while adding after it has failed. So when we declare attempts : 3, the job should be tried 1+3(fresh attempts + reattempts) times if we consider it has been failing all the time.

BullMQ documentation : https://docs.bullmq.io/guide/retrying-failing-jobs However, in the bull docs it says something different : https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queueadd

Could you please clarify how many times will a job get retried if attempt is 'n' ? and will those attempts include the fresh attempt as well?

Minimal, Working Test code to reproduce the issue.

(An easy to reproduce test case will dramatically decrease the resolution time.)

Bull version

Additional information

sanyaldips93 avatar Aug 30 '22 11:08 sanyaldips93

I am confused, what is the issue exactly? Did it not work as stated in the documentation?

manast avatar Aug 30 '22 20:08 manast

@manast The two documentations suggest quite the opposite idea. I wanted to understand and confirm if the number of attempts would include the fresh attempt and the attempts post failure as well?

For example : if the number of attempts were defined 3, would that indicate 1 fresh attempt and 2 retry attempts?

sanyaldips93 avatar Sep 01 '22 04:09 sanyaldips93

It's all in the wording. "retry" for example does not count the first because the first is actually the job. The docs are also very specific about WHEN to "retry".

When a processor throws an exception, the worker will catch it and move the job to the failed set. But sometimes, it may be desirable to retry a failed job.

This means, the job is "retried" WHEN the job throws an exception. When a job fails, the job is moved into the failed set and "retried" up to n times.

I agree that the comment docs could be a little more clear by adding "retry" to the wording there.

attempts: number; // The total number of RETRY attempts to try the job until it completes.

bugs181 avatar Sep 10 '22 19:09 bugs181

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 10 '22 11:11 stale[bot]