Function racing_conditional_appends_elect_one_winner
pub async fn racing_conditional_appends_elect_one_winner<F: Fixture>(
open: impl AsyncFn() -> F,
) -> RuleOutcomeExpand description
Two command handlers that decided from the same snapshot cannot both commit.
This is the race DCB exists to prevent, expressed deterministically:
both handlers read, both see position N, both append conditioned on
after: N with the same query. Whichever lands first invalidates the
other.
It is written sequentially and through one handle, which is less than
it sounds like. An earlier version of this note claimed a stronger
version would need Send + Sync + 'static bounds that EventStore
deliberately does not carry; that is true of a genuinely parallel
successor and false of the two-handle sequential one the fixture
contract now makes writable —
two_handles_observe_each_others_appends runs exactly this shape
across two connections with no extra bound anywhere.
§The parallel family exists, and this rule is retained beside it
This note used to end “adapters that are Send + Sync should add a
multi-threaded stress test of their own”. Do not. That family now ships:
event_store_concurrency_conformance!, eight contenders on real OS
threads against one backing store. Invoke it rather than writing your
own, and read the concurrency module’s documentation before you do.
Both names are spelled plainly rather than linked, and that is the same
discipline the model family’s three names are held to at the crate root:
the concurrency module is #[cfg(not(target_arch = "wasm32"))], this
file is not, and rustdoc treats an unresolved link as a hard error — so a
link here would break cargo doc --target wasm32-unknown-unknown, which
is the target this crate’s whole two-flavour story exists for.
Two corrections come with it, both measured rather than reasoned.
The bound is F::Store: EventStore + Send, not Send + Sync. Three
of the four obligations that sounded necessary — the Send flavour of
the port, Sync, and 'static — turned out not to be, because each
contender owns its handle and drives its own future on its own scoped
thread. concurrency.rs’s bound section names what the compiler said
about each part.
And the family is additive: this rule is retained, not retired. The
plan said stage 5 would retire it and the plan was wrong. What this rule
fixes is the semantics a race must have — which of two decisions taken
from one snapshot is allowed to land, which is ES-25’s iff seen as two
decisions from one snapshot, and two of the three registered mutants it
rejects are shapes ES-25’s own Rejects: paragraph names by hand. What
it structurally cannot do is separate an atomic check-and-write from a
probe followed by an insert, because with one caller at a time nothing
can get between the two halves. The parallel family supplies the second
caller. Neither subsumes the other, and deleting this one would leave the
semantics unpinned for every !Send adapter, which cannot run the
parallel family at all.
The old note’s remaining worry — that a parallel version risks a flaky
suite, which is worse than none — was taken seriously rather than
dismissed: the parallel rules synchronise on a
Barrier and on the other threads, never on a
clock, and CF-33 forbids the watchdog that would have been the tempting
alternative.