Skip to main content

Module group_commit

Module group_commit 

Source
Expand description

Group commit — batches concurrent WAL flushes into a single fsync.

§Model

Leader/follower group commit sitting at the WAL durability boundary (StorageManager commit_transaction step 1). Each submitting thread:

  1. Appends its WAL records (including the Commit record) under the WAL lock — without an fsync.
  2. Enqueues a pending flush request tagged with the thread’s LSN.
  3. Tries to become the leader; the leader drains the queue for GroupCommitConfig::drain_timeout, then performs a single fsync covering every drained request and delivers the shared durable_batch_lsn back to each waiter.
  4. Followers wait on their own result slot; if no leader finishes them within GroupCommitConfig::leader_timeout, they retry leadership (self-healing — e.g. a leader thread was descheduled).

The durability guarantee is preserved: a submitter only returns success after an fsync that started after it enqueued. Recovery format is untouched — this coordinates when an fsync happens, never what is written.

§Fsync target

GroupCommit is generic over WalLike; akar-storage implements it for Mutex<WAL>, so a whole group shares the same underlying WAL file.

Structs§

GroupCommit
Leader/follower group-commit coordinator over a shared WalLike target.
GroupCommitConfig
Group-commit configuration.
GroupCommitResult
Result delivered to a submitter once its group is durable.
GroupCommitStats
Simple cumulative statistics for observability.

Constants§

DEFAULT_DRAIN_TIMEOUT
Default time a leader keeps draining the queue before fsyncing.
DEFAULT_LEADER_TIMEOUT
Default time a follower waits before it attempts to take over leadership.

Traits§

WalLike
A durable flush target that many commits can share.