Skip to content

Fix intermittently failing test Test_Client_JobCompletion/JobThatReturnsErrIsRetryable#1247

Merged
brandur merged 1 commit into
masterfrom
brandur-fix-race-in-completion
May 11, 2026
Merged

Fix intermittently failing test Test_Client_JobCompletion/JobThatReturnsErrIsRetryable#1247
brandur merged 1 commit into
masterfrom
brandur-fix-race-in-completion

Conversation

@brandur
Copy link
Copy Markdown
Contributor

@brandur brandur commented May 11, 2026

Here, try to address an intermittently failing test seen in CI [1].

The problem seems to be that although the test case stubs the current
time with StubNow, it's possible for the producer's fetch loop to be
running concurrently and call NowOrNil() before the stub takes effect,
causing a divergence from the stubbed time by a few milliseconds.

The fix here drops the use of stubbed now, and instead asserts that the
new ScheduledAt is AttemptedAt plus the expected retry interval,
using a value from a reloaded job row to guarantee we don't have a race.
We drop the use of time stubbing completely as this approach no longer
requires it.

[1] https://github.com/riverqueue/river/actions/runs/25657083352/job/75308035231

…urnsErrIsRetryable`

Here, try to address an intermittently failing test seen in CI [1].

The problem seems to be that although the test case stubs the current
time with `StubNow`, it's possible for the producer's fetch loop to be
running concurrently and call `NowOrNil()` before the stub takes effect,
causing a divergence from the stubbed time by a few milliseconds.

The fix here drops the use of stubbed now, and instead asserts that the
new `ScheduledAt` is `AttemptedAt` plus the expected retry interval,
using a value from a reloaded job row to guarantee we don't have a race.
We drop the use of time stubbing completely as this approach no longer
requires it.

[1] https://github.com/riverqueue/river/actions/runs/25657083352/job/75308035231
@brandur brandur requested a review from bgentry May 11, 2026 08:15
@brandur
Copy link
Copy Markdown
Contributor Author

brandur commented May 11, 2026

Damn, fix for intermittently failing test reveals another intermittently failing test.

@bgentry
Copy link
Copy Markdown
Contributor

bgentry commented May 11, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

@bgentry bgentry left a comment

Choose a reason for hiding this comment

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

Much better to not have to care about stubbing time 🙌

@brandur brandur merged commit 11ebb22 into master May 11, 2026
26 of 27 checks passed
@brandur brandur deleted the brandur-fix-race-in-completion branch May 11, 2026 17:32
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