Expand description
Group commit coordinator.
Batches concurrent WAL write requests into a single fsync for maximum NVMe IOPS.
§How it works
- Multiple threads submit
PendingWriteto the commit queue. - One thread becomes the “commit leader” (acquires the commit lock).
- The leader drains all pending writes, appends them to the WAL writer,
issues a single
fsync, and advancesdurable_lsn. - Non-leader threads discover their write was already committed when the
pending queue is empty after acquiring the commit lock. They verify the
commit succeeded via
last_commit_failedbefore returningdurable: true.
This converts N fsyncs into 1 fsync, which is critical for NVMe performance.
§Safety invariants
durable_lsnis updated atomically only after a successful fsync.- If fsync fails,
last_commit_failedis set so non-leader threads whose writes were in the failed batch propagate the error instead of falsely reportingdurable: true. - Fsync failure is treated as fatal for the batch — the data may or may not be on disk, and the caller must handle the error (retry, abort, etc.).
Structs§
- Commit
Result - Result delivered to each waiter after group commit completes.
- Group
Committer - Thread-safe group commit coordinator.
- Pending
Write - A pending write request waiting to be committed.