Expand description
WAL-first journal batcher for durable ACKs in the engine hot path.
The engine pushes JournalEntry values into a bounded channel.
This task drains entries, appends them to a local WAL, calls fdatasync,
and only then allows ACK/event emission via commit_ack.
PostgreSQL replication runs asynchronously after WAL durability so client-visible latency is decoupled from network/database I/O.
Modulesยง
Structsยง
- Engine
Journal Batcher - The batcher that runs in the background and appends to local WAL first, then replicates to PostgreSQL asynchronously.
- Event
Payload - Pre-serialized event payload ready for DB storage. Contains wire-format bytes (version byte + msgpack) so no further serialization is needed.
- Journal
Batcher Config - Configuration for the journal batcher
- Journal
Cash Withdrawal Side Effect - Journal-only side effect for a CashWithdrawalUpdate command.
- Journal
Entry - A journal entry to be batched and durably appended.
- Journal
Fill Side Effect - Journal-only accounting deltas for a single OrderFilled event.
- Prepared
WalBlock ๐ - Replication
Progress ๐ - RsmBatch
Roots ๐ - RsmWal
Writer ๐State - WalBlock
Record ๐With Roots - WalDurable
Block ๐Entry - WalJournal
Record ๐ - WalRecord
With ๐Offset - WalState ๐
Enumsยง
- Journal
Message - Messages sent to the journal batcher.
- Replication
Message ๐ - WalWriter
Message ๐ - Messages sent from the batcher task to the dedicated WAL writer thread.
Constantsยง
- DEFAULT_
CHANNEL_ CAPACITY - Default channel capacity
- REPLICATION_
RETRY_ ๐DELAY - WAL_
PREALLOC_ ๐CHUNK - Pre-allocate WAL file in 64 MiB chunks to avoid extent allocation stalls.
Functionsยง
- append_
command_ ๐delta - append_
intent_ ๐delta - append_
obligation_ ๐delta - apply_
recovered_ ๐rsm_ commitment_ blocks - engine_
command_ ๐identity_ hashes - engine_
journal_ ๐entry_ insert - next_
replication_ ๐chunk_ len - Returns the number of records for the next replication chunk.
- rsm_
batch_ ๐roots_ from_ wal - rsm_
event_ ๐payload_ hash - rsm_
global_ ๐leaf - rsm_
hash_ ๐with_ domain - rsm_
state_ ๐delta_ from_ entries - rsm_
state_ ๐delta_ from_ parts - rsm_
state_ ๐supported_ command - should_
defer_ ๐replay_ record - wal_
fsync_ ๐io_ uring - Submit
IORING_OP_FSYNCwithDATASYNCflag via io_uring. - wal_
writer_ ๐thread_ main - Dedicated WAL writer OS thread.
Type Aliasesยง
- Journal
Batch Sender - Sender half for pushing journal entries
- Shared
Journal Batch Sender - Shared sender that can be cloned and used from the engine.
- WalBlock
Entry ๐ - WalBlock
Record ๐