You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
moonpool-journal: truncate_prefix unlinks before the new start is durable; a segment gap deletes the live log or panics on open #301
Downstream: PierreZ/paros#176, PierreZ/paros#202 (paros checkpoints with truncate_prefix, crates/paros/src/journal/node.rs:258-279). Distinct from #293, which is about ancestors on open. References: moonpool 9ed1360, paros f2b2502.
Downstream evidence.Journal::truncate_prefix deletes the dropped segments oldest first and then runs one sync_dir (crates/moonpool-journal/src/journal.rs:603-631). Nothing durable says the log's start moved before the unlinks. With unsynced_dir_entry_loss_probability (in the default random profile, storage/config.rs:442-500) each name resolves on its own at a crash (storage/sim/engine.rs:798-835), so a crash in that window can bring back seg-1 while seg-2 stays deleted: [seg-1, seg-3, …], a gap.
On the next open Segment::walk computes its index limit from the next segment's name (segment.rs:430, limit = next_first - first):
if seg-1 rolled over because its data region filled, the walk meets the first empty slot past its real end, sets ended, and open deletes every later segment, newest first (journal.rs:240-249): the whole live log, acknowledged entries included, is gone;
if seg-1 rolled over because its slot table filled, limit exceeds slot_count, and failed[at / BLOCK] / table[at..] index past the table (segment.rs:441-444): a panic.
Neither crash loop calls truncate_prefix and neither enables directory-entry loss (tests/journal.rs:1217-1278), so this is untested. For paros it is a lost acceptor after a checkpoint plus a power loss, in production too.
Smallest change.
Record the new start durably before any unlink: a start_index field in the two-copy metadata (DualFile, beside the caller's payload, or its own start.0/1 pair), written and synced first. start_index() reads it; open deletes any segment wholly below it (a resurrected one) and treats a segment missing between the start and the tail as JournalError::BadSegmentHeader-class damage, never as the end of the log. walk's limit comes from the slot table, with the next segment's name only a cross-check.
This also gives a caller an index-granular floor the journal remembers: today a reopen reports the oldest segment's first index, so paros keeps its own floor in every Truncate record.
fill three small segments, truncate_prefix past the second, crash with unsynced_dir_entry_loss_probability = 1.0 arranged so the first deletion is undone and the second kept, reopen: every live entry is readable, nothing past the start is deleted, no panic. Red today in both shapes (the data-full and the table-full rollover).
the crash loop's write plan gains truncate_prefix, under the Paper model with directory-entry loss on, with the existing "nothing acknowledged is lost" oracle.
Activity
fix(moonpool-journal): a durable start before prefix unlinks; no gap …
feat(moonpool-journal): checkpoint batches, a batch that supersedes t…
fix(moonpool-journal): a durable start before prefix unlinks; no gap …
feat(moonpool-journal): checkpoint batches, a batch that supersedes t…
fix(moonpool-journal): a durable start before prefix unlinks; no gap …
feat(moonpool-journal): checkpoint batches, a batch that supersedes t…