sidequest icon indicating copy to clipboard operation
sidequest copied to clipboard

max_retries doesn't always apply

Open robcresswell opened this issue 10 months ago • 12 comments

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.

robcresswell avatar Jan 21 '26 22:01 robcresswell

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.

GiovaniGuizzo avatar Jan 26 '26 13:01 GiovaniGuizzo

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()

robcresswell avatar Jan 26 '26 14:01 robcresswell

retry()? Where?

GiovaniGuizzo avatar Jan 26 '26 14:01 GiovaniGuizzo

As in, https://docs.sidequestjs.com/jobs/convenience-methods#retry-reason-delay-method

robcresswell avatar Jan 26 '26 15:01 robcresswell

Ah, right. Let me check this if it's a bug.

GiovaniGuizzo avatar Jan 26 '26 17:01 GiovaniGuizzo

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.

GiovaniGuizzo avatar Jan 26 '26 17:01 GiovaniGuizzo

Image

Here is screen shot of the job.

GiovaniGuizzo avatar Jan 26 '26 17:01 GiovaniGuizzo

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.

robcresswell avatar Jan 26 '26 17:01 robcresswell

Ahhhh, I see. Let me check this again.

GiovaniGuizzo avatar Jan 26 '26 17:01 GiovaniGuizzo

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 :)

GiovaniGuizzo avatar Jan 26 '26 17:01 GiovaniGuizzo

No worries, thank you for working through the issue with me and sorry for the misleading first guesses.

robcresswell avatar Jan 26 '26 18:01 robcresswell

:tada: This issue has been resolved in version 1.13.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sidequest-release[bot] avatar Jan 26 '26 23:01 sidequest-release[bot]