Repository navigation
Description
Downstream: PierreZ/paros#176 (every paros role on moonpool-journal under Chaos::Storage). References: moonpool 9ed1360, paros f2b2502.
Downstream evidence. Every append rewrites bytes an earlier fdatasync already made durable:
Segment::appendstarts its data write at the block the previous batch ended in, filling the lead of the buffer from a cached copy of that block's acknowledged bytes (crates/moonpool-journal/src/segment.rs:595-648, thetailcache);write_slotsrewrites whole 4 KiB slot-table blocks from memory, so one new slot rewrites up to 63 acknowledged ones (segment.rs:471-496).
The simulated disk drops a sector's durability stamp on any write (crates/moonpool-sim/src/storage/image.rs:293-311), so those sectors re-enter the unsynced set and the crash model may resolve them Lost, LatentFault or Shorn. StorageConfiguration::random_for_seed, what Chaos::Storage(Random) and Swarm draw, sets crash_lost_probability up to 10 % and crash_latent_fault_probability up to 5 % (storage/config.rs:442-500). A crash in the window between the two writes of a batch and its sync can then destroy an acknowledged entry, its slot, or both: a DoubleFault on an acknowledged Paxos vote, and the journal refuses to open. The crate docs call this "harsher disks" (lib.rs, The fault model) and the crash loop only checks that the damage is reported under the Harsh model (tests/journal.rs:870-884). The lost-synced-write oracle cannot see it, by design: the sector was legitimately rewritten.
For paros this is the difference between "every storage fault moonpool can inject is in contract" and not: an acceptor that loses an acknowledged accept breaks quorum intersection, and ReplicatedFaults cannot keep a record safe when the journal's own write pattern is what exposes it. The same pattern is a torn-sector hazard on a real disk (a 512-byte sector shared by an old entry and a new one). TigerBeetle pads every prepare to its own sectors and writes a redundant header sector only after the prepare landed; FoundationDB's DiskQueue starts every commit on a fresh page.
Smallest change.
- Start every batch's entries on a fresh I/O-alignment block (
BlockFileblock, or the file'sconstraints()alignment when direct I/O is on). The last block of a batch is padded;data_endmoves to the next block boundary. Thetailcache goes. - For the slot table, either write only the sectors that hold new slots (sector-granular writes through
write_at, keeping the block arithmetic for direct I/O), or accept that a slot block is rewritten and rely on the existing rebuild from an intact entry row: with (1) in place the entry can no longer be lost by the same crash, so a lost slot is always rebuilt and never aDoubleFault. The docs should say which.
Cost: up to one block of padding per batch, which paros batches per Ready, so a few hundred bytes to 4 KiB per sync. Space, not syncs.
Determinism. No new draws. The write pattern changes, so every seed names a different run; the same seed must still replay.
Acceptance. In crates/moonpool-journal/tests/journal.rs:
- the
Harshcrash loop gains thePapermodel's oracle: no acknowledged entry is ever lost, reported corrupt, or reported ambiguous, undercrash_lost_probability0.3,crash_latent_fault_probability0.1,shorn_write_probability0.2. Red today (the current harsh oracle only requires the damage to be reported). - A targeted test: append batch A, sync, append batch B of one small entry that shares A's last block today, crash with every dirty sector
Lost, reopen: A's last entry is intact. cargo xtask sim run journalunderChaos::Storage(ChaosMode::Random)with theKeeppolicy, and the example'sassert_always!triple unchanged.
Activity
test(moonpool-sim-examples): the journal example under Chaos::Storage…
fix(moonpool-journal): start every append batch on a fresh block
fix(moonpool-journal): reserved slot records, and a torn identifier i…
test(moonpool-sim-examples): the journal example under Chaos::Storage…
fix(moonpool-journal): start every append batch on a fresh block
fix(moonpool-journal): reserved slot records, and a torn identifier i…
test(moonpool-sim-examples): the journal example under Chaos::Storage…