Skip to content

test(api): drop an assertion on who won a race with the drainer - #70

Merged
DanielWLiu07 merged 1 commit into
mainfrom
fix/flaky-request-race
Sep 7, 2026
Merged

DanielWLiu07 merged 1 commit into
mainfrom
fix/flaky-request-race

Conversation

@DanielWLiu07

Copy link
Copy Markdown
Owner

RequestIsSafeUnderConcurrentPublishAndDrain asserted served > 0: that at
least one of 20,000 request() calls found a value in the subscriber's slot.
The drainer in the same test is a tight loop emptying that slot, so the
assertion is a statement about scheduling, not about the code under test.

It passed 200 consecutive local runs and failed once in CI, under the BDE
allocators on a loaded runner:

99% tests passed, 1 tests failed out of 241
  49 - ConflatingSession.RequestIsSafeUnderConcurrentPublishAndDrain (Failed)

A re-run with no code change went green, which is the definition of the
problem.

Nothing is lost

That request() returns a present value is already pinned deterministically
by RequestReturnsTheCurrentValueWithoutSubscribing and
RequestSeesTheLatestValueNotTheFirst. The assertion this test actually
exists for, requests_served + requests_denied == 20000, is unaffected by
who wins the race and still runs.

The test's own comment already said the right thing - "the exact value read is
whatever was current at that instant" - and then asserted otherwise on the
next line.

A test that reddens the build at random teaches you to ignore red.

RequestIsSafeUnderConcurrentPublishAndDrain asserted served > 0: that at
least one of 20,000 request() calls found a value in the slot. The drainer
in the same test is a tight loop emptying that slot, so the assertion is a
statement about scheduling, not about the code under test. It passed 200
consecutive local runs and failed once in CI under the BDE allocators on a
loaded runner.

Nothing is lost. That request() returns a present value is pinned
deterministically by RequestReturnsTheCurrentValueWithoutSubscribing, and
the assertion this test exists for - requests_served + requests_denied
equals the number of calls made - is unaffected by who wins the race.

A test that reddens the build at random teaches you to ignore red.
@DanielWLiu07
DanielWLiu07 merged commit 4785891 into main Sep 7, 2026
9 checks passed
@DanielWLiu07
DanielWLiu07 deleted the fix/flaky-request-race branch September 7, 2026 05:25
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.

1 participant