Repository navigation
Description
Downstream: PierreZ/paros#176. The second half is the "also worth deciding" note of #289, which PR #291 did not address. References: moonpool 9ed1360, paros f2b2502.
Downstream evidence. Two rules of the slot table disagree with the record contract paros decided on in PierreZ/paros#20 and recorded in docs/analysis/storage/clstore-record-contract.md ("every slot is formatted with a real, checksummed reserved record carrying its own slot identity, so all-zeros is always faulty, never empty"), and with the contract doc on LogStorage::boot_scan (crates/paros/src/storage/mod.rs:246-273). Today paros's doc describes a journal that does not exist; one side has to move, and this issue proposes the journal does.
-
All zeros means "never written" (
crates/moonpool-journal/src/layout.rs:301,SlotState::Empty). So a synced slot that comes back zeroed (aLostsector past the garbage-fill prefix, a zero-filled EIO block that the walk treats asBadtoday only because the read failed, a misdirected write of a zero page) reads as absent and, beside a damaged entry, ends the log:scan::decidetakes(None, Empty)as the torn tail (scan.rs:100-103). That is CTRL's Figure 2 bug in disguise: an acknowledged entry past it is silently cut. TigerBeetle's answer is a reserved header per slot whoseopis the slot index, fully checksummed, so zeros are always a fault and a reserved record in the wrong slot is a misdirect (vsr/journal.zig, "the op for reserved headers is set to the corresponding slot index"). The segment file is already preallocated and written whole at creation (segment.rs:229-271), so formatting the table with reserved slots costs nothing extra. -
A bad slot beside a bad entry is a
DoubleFaulteverywhere, the last batch included (scan.rs:104). The last batch's entries and slots reach the disk through two unordered writes and one sync (lib.rs, Appending); a crash before that sync, withshorn_write_probabilityor a garbage fill, tears both and the node never boots again although nothing was acknowledged. moonpool-journal: expose where an entry lives on disk, for targeted fault injection #289 raised this and it is still open in the code.
Smallest change.
- Format every slot of a new segment with a reserved record: index = its slot's index, epoch 0, a
reservedflag, CRC over the lot.SlotStatebecomesReserved(index)/Valid/Bad; a reserved record naming another index isBad(misdirected).truncate_suffixand the open-time clean-up write reserved records instead of zeros, so "past the end" stays loud. - In
decide, a slot that isBadbeside a damaged entry inside the last batch ends the log like a reserved slot does (the batch-start flag already locates the last batch,segment.rs:565-572); outside the last batch it stays aDoubleFault. Recoveryreports which rule fired:torn_tailfor a reserved or torn identifier in the last batch,DoubleFaultotherwise.
Format version bump (FORMAT_VERSION, layout.rs); no deployment runs the old one.
Determinism. No new draws.
Acceptance (crates/moonpool-journal/tests/journal.rs, tests/journal_atlas.rs):
- zero a synced slot (through its
JournalAtlas::slotregion) beside an intact entry: the slot is rebuilt, the log is not cut; beside a damaged entry before the last batch:DoubleFault, never a truncation. Red today (the second case truncates silently). - Damage both the entry and the slot of an entry in the last batch: opens with
torn_tail, the batch is gone, everything before it intact. Red today (DoubleFault). - The crash loop under
shorn_write_probability0.2 andgarbage_fill_probability1.0 never refuses to open when nothing in the last batch was acknowledged.
Activity
fix(moonpool-journal): start every append batch on a fresh block
fix(moonpool-journal): reserved slot records, and a torn identifier i…
fix(moonpool-journal): start every append batch on a fresh block
fix(moonpool-journal): reserved slot records, and a torn identifier i…