Skip to content

Make job rescue paginated to protect against full batch of no-rescue jobs#1318

Merged
brandur merged 1 commit into
masterfrom
brandur-paginated-rescue
Jul 22, 2026
Merged

Make job rescue paginated to protect against full batch of no-rescue jobs#1318
brandur merged 1 commit into
masterfrom
brandur-paginated-rescue

Conversation

@brandur

@brandur brandur commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This one's aimed at fixing a long-standing bug accidentally detected
while working on another rescue-related feature.

The JobRescuer works by fetching a full batch of jobs to rescue then
going through each one to determine what it should be doing about it.
The default batch size is 10k, so this generally works perfectly fine.

Some stuck jobs are potentially not rescued if their timeout is
configured to be -1 (no timeout).

Codex identified a tail bug possibility in which if you had an entire
batch worth of jobs with -1 timeouts, they'd block any jobs after them
from being rescued. So the rescuer would rescue 10k jobs, determine none
of them needed rescue, then go back to sleep, stranding any jobs after
that.

This is such a tail possibility that it's probably fine, but just since
we're making changes to the rescue driver boundary right now anyway,
it's not a bad time to just get this one fixed up.

Comment thread CHANGELOG.md Outdated
### Fixed

- Guard against empty job slice returned by `JobSetStateIfRunningMany` when a job has been deleted mid-run. [PR #1308](https://github.com/riverqueue/river/pull/1308).
- Fixed `JobRescuer` pagination so a full batch of running jobs with disabled or longer worker-specific timeouts can't prevent later stuck jobs from being rescued.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR number?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, fixed.

Base automatically changed from brandur-pilot-job-get-stuck to master July 22, 2026 18:31
…jobs

This one's aimed at fixing a long-standing bug accidentally detected
while working on another rescue-related feature.

The `JobRescuer` works by fetching a full batch of jobs to rescue then
going through each one to determine what it should be doing about it.
The default batch size is 10k, so this generally works perfectly fine.

Some stuck jobs are potentially not rescued if their timeout is
configured to be -1 (no timeout).

Codex identified a tail bug possibility in which if you had an entire
batch worth of jobs with -1 timeouts, they'd block any jobs after them
from being rescued. So the rescuer would rescue 10k jobs, determine none
of them needed rescue, then go back to sleep, stranding any jobs after
that.

This is such a tail possibility that it's probably fine, but just since
we're making changes to the rescue driver boundary right now anyway,
it's not a bad time to just get this one fixed up.
@brandur
brandur force-pushed the brandur-paginated-rescue branch from 760f083 to 4ce6835 Compare July 22, 2026 18:39
@brandur
brandur merged commit 489824c into master Jul 22, 2026
15 checks passed
@brandur
brandur deleted the brandur-paginated-rescue branch July 22, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants