Skip to main content

Module spool

Module spool 

Source
Expand description

Durable-across-process-crash local spool for the AU-5 degraded path.

The spool holds exactly the chained audit records that are not yet written to the topic, in order. By default, append calls fsync before it returns success. Callers that explicitly choose a wider sync cadence can batch that cost and use Spool::sync when they need a durable acknowledgement. open heals and durably truncates a torn tail frame from a crash during an append.

File: a header (the magic KAUD, then the i16 version), then frames. Frame: [u32 len][record]. Record: [u8 class_tag][u32 value_len][value][u32 header_count]([u32 klen][k][u32 vlen][v])*. This module uses synchronous std::fs, because the path is degraded and low-frequency. It treats a truncated or corrupt tail frame as end-of-data, but a missing or unknown file header as a hard error.

The sidecars carry the same header: audit.losses then holds the u64 generation and the u64 count, audit.replay-offset the u64 offset, and audit.replay-poison the u64 offset and one frame. Every offset and byte count here is into the frames, after the header.

Structsยง

Spool
Append-only durable spool file.