Skip to content

test: see that the calls of a race overlapped, on every run - #9

Open
JasonYv wants to merge 1 commit into
feature/inquiry-cartfrom
test/deterministic-race-tests
Open

JasonYv wants to merge 1 commit into
feature/inquiry-cartfrom
test/deterministic-race-tests

Conversation

@JasonYv

@JasonYv JasonYv commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Stacked on #8 (the inquiry cart). Tests only; nothing under src/ changes.

What this is

The review of the inquiry cart showed that two requests sent with Promise.all interleave only about half the time. This looks at the nine older tests of a race — a payment reported twice at once, two refunds, a payment against a cancellation — for the same weakness.

They do not have it. They call functions side by side rather than send requests, and such calls overlap every time: in twenty-five rounds of two payments at once, both readings reached the database before either write, in one and the same order.

So none had to be rewritten. What changes is that this is now seen on every run instead of taken on trust: the nine run through atTheSameMoment, which hands each call a database that notes when it is used and fails unless every call had read before any wrote. A change that put a wait in front of a reading would have turned such a race into a sequence and left its test passing.

How it was verified

Check Result
lint, type check, tests Pass: 779 inside workerd
The helper itself has tests of its own, for the calls it must refuse
Red and green with everything that stops its second write taken away, each of the nine was red eight times in eight

One thing that showed: a payment's write is stopped by several keys at once, so removing the shared status condition turns no race between two payments red. The races between two different changes of an order have no key in common, and do go red without it.

An independent review showed that two requests sent with Promise.all
interleave only about half the time. The nine older tests of a race —
payments, refunds, cancellations — call functions side by side instead, and
a probe found those overlap every time: both readings before either write,
in twenty-five rounds of twenty-five.

They now run through atTheSameMoment, which gives each call a database that
notes when it is used and fails unless every call had read before any wrote.
A change that put a wait in front of a reading would have turned such a race
into a sequence and left its test passing; now it fails. The helper has
tests of its own, for the case it must refuse.

With everything that stops its second write taken away, each of the nine was
red eight times in eight.
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