Skip to main content

a_busy_append_left_nothing_behind

Function a_busy_append_left_nothing_behind 

pub async fn a_busy_append_left_nothing_behind<F>(
    open: impl AsyncFn() -> F,
) -> RuleOutcome
where F: Fixture, F::Store: EventStore + Send,
Available on non-WebAssembly only.
Expand description

An append answered Busy left nothing in the store.

ES-43’s no-effect half, and the half no other rule can see. A refusal that wrote nothing and a refusal that wrote the batch return the same value, so the only way to tell them apart is to read back what the refused contender would have written. Each contender here appends a batch carrying a tag of its own, so that read names exactly one caller’s events and nobody else’s.

The defect is BusyAfterWriteStore in the proof artefact. It commits the batch and then answers Busy, which is what an adapter does when it treats a client-side deadline that fired after COMMIT was sent as a transient refusal, or reclassifies a SQLITE_BUSY without asking whether the rows were already written. A caller that believes the answer re-runs the command, and an unconditional append lands twice.

§It observes, and does not force

No portable way exists to make a store answer Busy, and ES-43 never obliges one to. So this rule races CONTENDERS contenders and checks every Busy answer it happens to get. Against a store that never reports Busy it passes on its anchor alone, and that is what ES-43 asks of such a store. The deterministic arm lives in the testkit’s own tests/contended_store_instruments.rs, where contend_next makes refusals certain.

Each append is conditional, on a query only that contender writes to. Such a condition can never legitimately be violated. It is here because a store that retries serialisation failures only runs that path for a conditional append, and that path is where a Busy is most likely to come from.

The committed contenders are read back too, and that anchor is not decoration. Without it a store whose reads return nothing would pass the Busy half vacuously, because an empty answer is exactly what that half asks for.