Skip to content

make producer race test deterministic - #1335

Merged
bgentry merged 1 commit into
masterfrom
bg/producer-race-test
Jul 31, 2026
Merged

make producer race test deterministic#1335
bgentry merged 1 commit into
masterfrom
bg/producer-race-test

Conversation

@bgentry

@bgentry bgentry commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This is a draft alternative to #1248.

The existing race regression test processes 10,000 jobs and relies on the final job starting within a fixed deadline, so race-enabled CI can fail from throughput variance even when the intended concurrency path is exercised.

Replace it with a coordinated three-job scenario that blocks fetches after capacity is calculated. The test completes jobs while fetches are pending, continuously reads capacity across active-job removals and additions, and asserts each capacity transition. A queued third job preserves backlog/refill coverage, and the scenario runs through both poll-only and notifier producer setups.

This guarantees the completion-during-fetch overlap without a wall-clock throughput deadline and keeps unsafe active-job accounting visible to the race detector without adding production-only test instrumentation.

@bgentry
bgentry force-pushed the bg/producer-race-test branch 3 times, most recently from 233208a to 4adcaf3 Compare July 31, 2026 16:11
The producer concurrency regression processes 10,000 jobs and relies
on finishing the last one within a fixed deadline. Race-enabled CI can
exercise the intended overlap many times and still fail solely because
it misses that throughput deadline.

Replace the workload with a coordinated three-job scenario that blocks
fetches after capacity is calculated. Complete jobs while fetches are
pending and read capacity concurrently across removals and additions.
This keeps unsafe active-job accounting visible to the race detector.

Assert each capacity transition and verify that a queued third job runs
after a slot reopens. Run the scenario through both poll-only and
notifier producer setups, using the pilot seam so no production-only
test signal is needed.

Keep reusable test plumbing generic with a pre-fetch pilot hook while
the scenario owns its fetch schedule. Use zero-based job indices and
single-owner gate cleanup. Stream capacity transitions in order, with
cancellation-aware sends, so failures cannot strand the observer.

Document the gated sequence so completion during a pending fetch, the
retained fetch limit, refill timing, and observer lifetime are explicit.
@bgentry
bgentry force-pushed the bg/producer-race-test branch from 4adcaf3 to a470e47 Compare July 31, 2026 16:24
@bgentry
bgentry marked this pull request as ready for review July 31, 2026 16:59
@bgentry
bgentry requested a review from brandur July 31, 2026 16:59
@bgentry

bgentry commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Oops thought I sent this comment earlier:

@brandur this is still not the easiest test to read, but I do think it retains the coverage of the old test while being fully deterministic.

@bgentry
bgentry merged commit 0780aa9 into master Jul 31, 2026
15 checks passed
@bgentry
bgentry deleted the bg/producer-race-test branch July 31, 2026 17:16
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