max_retries doesn't always apply
Using manual retry logic seems to be able to get the database into a state where jobs retry infinitely and dont obey max retries. We have several rows in our sidequest tables where the current attempt is higher than max.
There is only one case where max_retry is not honored by Sidequest, and that's when the user manually clicks on "rerun" on the dashboard, or when the user programmatically reruns a job. If it's at max_retries, it will increment it by one. That's the only occasion and it's expected behavior.
Hmm. We don't have the dashboard enabled, and observed multiple jobs with the max attempts above the attempts count, in jobs where people were using retry()
retry()? Where?
As in, https://docs.sidequestjs.com/jobs/convenience-methods#retry-reason-delay-method
Ah, right. Let me check this if it's a bug.
I cannot reproduce the issue. If I run something like this:
import { Job, logger } from "sidequest";
export class RetryJob extends Job {
async run() {
logger("RetryJob", `Retry ${this.attempts} attempt`);
return this.retry("RETRY");
}
}
It fails at the 5th attempt.
Here is screen shot of the job.
I'll see if I can produce a minimal repro. My guess for when it was occurring was when jobs were timing out or something; it seemed like the logic for re-queueing stale jobs didn't consider attempts, and just put them back into waiting, I think. So perhaps the retry() was a misdirect.
Ahhhh, I see. Let me check this again.
Yeah, that's it. It's a bug in the stale cleanup logic. I will work on a fix later this afternoon. Thanks for bringing this up :)
No worries, thank you for working through the issue with me and sorry for the misleading first guesses.
:tada: This issue has been resolved in version 1.13.5 :tada:
The release is available on:
v1.13.5- GitHub release
Your semantic-release bot :package::rocket: