Skip to main content

Module workload

Module workload 

Source
Expand description

The concurrent write workload and result collection for the oracle.

Each writer interleaves three op streams against the replica Dispatcher:

  • Contended RMW on a small set of shared keys — read the current record, append this op’s globally-unique id to the record’s comma-separated set, and conditionally put against the revision just read. On Conflict, re-read and retry (bounded). This is the arbitration proof: if conditional writes are correct, every committed op-id survives in the final set.
  • Lifecycle ops (#203) on a small set of life-* keys — edit, delete, or recreate, chosen by a per-run lifecycle counter (lifecycle_op_for). Each op reads the key, then issues one conditional write against what it read. A lost race is recorded as Conflict and not retried. Deletes therefore race edits and recreations across replicas, and afterwards every replica must agree on whether each key is deleted.
  • Unique-key writes — disjoint keys written once, later read back to prove no acked write is lost across replica kills. The first unique_deletes_per_writer of each writer’s acked keys are then deleted and must still read as tombstones at the end (no resurrection under churn).

After all writers finish, run reads the contended and unique keys through the dispatcher. The per-replica lifecycle read, collect_lifecycle, is a separate call because it must reach every replica directly. The caller runs it once all replicas are live again.

Structs§

WorkloadConfig
Workload shape. The bounded gate and the deep soak both use this; they differ only in the magnitudes and (for the deep soak) running against a duration.

Functions§

collect_lifecycle
Read every lifecycle key from every replica directly (raw and consumer). Call only after the writers have stopped and all replicas are live: a final read retries up to 3 attempts, 200 ms apart, on errors only, so a connection pooled to a just-restarted replica doesn’t fail the soak on its own; a replica that stays unreadable is still reported (FinalReadFailed).
lifecycle_key_for
The key a lifecycle id targets. Divides by 4 (the op cycle length) before taking the modulus so the key and the op are decorrelated: every key sees every op kind.
lifecycle_op_for
The op a lifecycle id performs: a quarter deletes, a quarter recreations, and half edits (so deletes race live writes, which is what makes them conflict).
raw_state
Classify one raw read for the oracle. Revisions render as "<counter>:<hash>".
run
Run the workload to completion and collect stats for the oracle. dispatcher fans ops across the live replicas; chaos (replica kills) is driven separately by the caller while this runs. lifecycle is left empty: fill it with collect_lifecycle once every replica is live.