Skip to main content

Module commit_waiter

Module commit_waiter 

Source
Expand description

Synchronous commit waiter (PLAN.md Phase 11.4 — ack_n).

Bridges the primary’s commit path with replica ACKs. The commit caller picks a target_lsn (the LSN it just made durable locally) and asks the waiter “block until at least N replicas have ack’d this LSN, or the timeout expires.” Replica ACK RPCs call record_replica_ack which signals every waiter whose threshold is now met.

§Thread safety

The waiter uses a Mutex<State> + Condvar so the await_acks call blocks the caller’s thread without spinning. Acks bump a per-replica last_durable_lsn map and broadcast on the condvar. Waiters wake, recompute the count of replicas at or past their target, and either return Ok(count) or re-wait.

§Why this is just the foundation

The actual write commit path doesn’t yet call await_acks — wiring it in touches every public mutation surface and changes latency characteristics across the board. This module ships the primitive + the ack registry so the wiring change can land as one focused PR per surface (HTTP, gRPC, wire protocol) rather than a single massive diff.

Structs§

CommitWaiter
CommitWaiterMetrics
Outcome counters for /metrics. PLAN.md Phase 11.4 — operators alert on timed_out rising (commit policy is too tight or replicas are stalled) and watch last_wait_micros for the p95.

Enums§

AwaitOutcome