Repository navigation
feat(moonpool-journal)!: rewrite as a position-keyed CLSTORE journal - #308
Merged
Merged
Conversation
The journal is rewritten from scratch. The old design was a dense Raft-shaped log (index, epoch, 24-byte tag, suffix truncation only), which forced a Paxos caller to journal operations and fold them at boot, with checkpoint brackets and a second recovery algorithm on top. The new journal implements CLSTORE (PAR/CTRL, FAST '18) and knows no protocol: - An entry is a u64 position plus an opaque 24-byte Id. Positions are written in any order, with gaps and overwrites (a lagging replica fills old positions while new ones arrive). Payloads go to an arrival-order entry log. Batch::clear adds tombstones, Batch::truncate_prefix raises the floor and frees whole segments from the front, and Batch::set_meta replaces up to 4 KiB of metainfo. No snapshots, no compaction. - Each segment holds a persist log of 64-byte records (CLSTORE's identifier and persist record in one) and an entry log whose headers repeat the record's identity. Every batch starts on a fresh block in both, so no write touches an acknowledged sector. A segment header links to the last batch before it, so a missing segment is never read as the end. - The metainfo lives in its own file, as two copies written one after the other, so at most one is ever in flight. - Durability::Batched is the paper's protocol (one fsync; the last batch's damaged entries are Ambiguous). Durability::Ordered syncs the entries before writing the records (two fsyncs; damage is always decided). It is recorded per batch and may change between opens. - Recovery rebuilds a damaged record from its intact entry, reports a damaged entry beside a valid record as Corrupt (or Ambiguous), discards torn records of the last batch durably, and refuses double faults, lost batches and lost metainfo. - Journal::regions and Journal::layout list the on-disk regions as LayoutRegions striped by position, replacing JournalAtlas. The crash loops found four bugs on the way, each fixed here: - create made the directory's name durable only in its immediate parent, so a crash lost the whole journal. Every ancestor is now synced. - open rewrote rebuilt persist records before the entries they came from (a predecessor's unsynced writes in the page cache) were durable, so a crash produced a record naming an entry that never landed. Entries are now synced first. - open repaired a metainfo copy while the other was still unsynced, so one crash could tear both. The meta file is now synced before any repair. - a record left unreadable by a crash (a latent sector) could read back after a later open had reused its batch number. Every open now durably bumps an open generation carried in batch numbers, and a record from an older generation beyond what the next open found is treated as garbage. Tests: one per row of the recovery table, metainfo copies, lost batches and segments, and crash loops under the paper's fault model and moonpool's full physics for Ordered, Batched and a mode drawn per round, with crashes inside recovery. All six combinations ran green at 10,000 seeds before the last change (deleting dead segments one at a time, each unlink synced before the next); after it, the default 120-seed loops pass. The accept_log example, the sim-journal example (50/50 iterations), the README and the book chapter are rewritten for the new API. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Gmo6Uek5zmkF8DrUSpAzCn
…etainfo A read-only probe: no recovery, no repair, no sync, nothing created, so a caller can ask whether a store is formatted without changing what the next open finds (paros's boot-kind check needs it). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Gmo6Uek5zmkF8DrUSpAzCn
…ility The two crash-loop tests ran all three durability settings each, past CI's 60s kill on a loaded runner. Six tests, about 6s each in the debug profile, run in parallel within the campaigns group. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Gmo6Uek5zmkF8DrUSpAzCn
…y one segment A batch must fit one empty segment; commit refused a bigger one with BatchTooLarge and gave the caller no way to know the bound. paros's acceptor, catching up a long log after a reboot, staged it as one batch on the small geometry and was refused on every boot. fits is now the one rule commit checks; fits_another lets a caller pack its writes into commits that each fit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Gmo6Uek5zmkF8DrUSpAzCn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The old journal was a dense Raft-shaped log (index, epoch, 24-byte tag, suffix truncation only). Paros could not store Paxos state in it, so it journaled operations and folded them at boot, with checkpoint brackets and a second recovery algorithm on top. This rewrite makes the journal protocol-agnostic so paros can use it directly.
What
A from-scratch CLSTORE journal (PAR/CTRL, FAST '18): detect, disentangle crash vs. corruption, identify.
u64position + an opaque 24-byteId.Batch::putwrites any position ≥ floor, with gaps and overwrites (laggy replicas). Payloads go to an arrival-order entry log.clear(range),truncate_prefix(floor),set_meta(bytes)(≤ 4 KiB, two copies). No snapshots, no compaction.<dir>/meta(two copies, written one after the other) andseg-<first batch>.walsegments: header ×2 | persist log of 64-byte records | guard gap | entry log. Every batch starts on a fresh block in both logs, so no write touches an acknowledged sector. Segment headers link to the previous batch, so a missing segment is refused.Durability.Batched= the paper'swrite(e); write(p); fsync(last batch's damaged entries areAmbiguous);Ordered=write(e); fsync; write(p); fsync(always decided, the default). Recorded per batch.Corrupt(orAmbiguous); both damaged in the last batch → torn, discarded durably; earlier →DoubleFault. PlusLostBatch,MetaLost,BadSegment,WrongJournal.Journal::regions()/layout(position)returnLayoutRegions striped by position, replacingJournalAtlas.Bugs the crash loops found (fixed)
createsynced only the immediate parent: a crash lost the whole journal → sync every ancestor.Testing
Ordered,Batchedand a mode drawn per round, with crashes inside recovery. Green at 10,000 seeds per combination (~1.95M commits) before the final change (segments unlinked one at a time, each synced); default 120-seed loops green after it.accept_logexample (self-checking),wasm32check, rustdoc, andsim-journal(50/50 iterations).Draft until paros validates it on its own simulation.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Gmo6Uek5zmkF8DrUSpAzCn
Generated by Claude Code