fix(job-queue): retry promptly when an idle peek finds a ready job - #712
Merged
Conversation
A worker that woke on a submit notify claims before the job's visible_at deadline and peeks after it, so getIdleDelay saw an already-visible head job and returned the full poll interval — stranding claimable work for the whole interval. This is what made the Supabase fast-wake test flaky in CI: with a 60s poll interval and PGlite round trips slower than the 200ms deferral under load, the deferred job was never picked up and the test timed out at 5s. Treat an already-visible head job as "retry soon" instead, backing off exponentially from 5ms up to the poll interval so a head job that stays visible-but-unclaimable (clock skew between worker and storage) degrades to plain polling rather than spinning on the backend. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sCJvLZjRzfQ8c2epuEmm5
Coverage Report
File CoverageNo changed files found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A worker that woke on a submit notify claims before the job's visible_at
deadline and peeks after it, so getIdleDelay saw an already-visible head
job and returned the full poll interval — stranding claimable work for
the whole interval. This is what made the Supabase fast-wake test flaky
in CI: with a 60s poll interval and PGlite round trips slower than the
200ms deferral under load, the deferred job was never picked up and the
test timed out at 5s.
Treat an already-visible head job as "retry soon" instead, backing off
exponentially from 5ms up to the poll interval so a head job that stays
visible-but-unclaimable (clock skew between worker and storage) degrades
to plain polling rather than spinning on the backend.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_012sCJvLZjRzfQ8c2epuEmm5