Repository navigation
feat: layout-aware storage chaos (JournalAtlas, FaultFocus, replicated fault patterns) - #291
Merged
Merged
Conversation
A fault injector that knows the journal's layout can aim where recovery
has to decide instead of spreading damage over a segment that is mostly
preallocated zeros. `Atlas` names every region recovery reads and
locates it as a file and byte range:
- `Region::Header { segment, copy }`, `Slot(id)`, `Entry(id)` and
`Meta { copy }`, each one tied to its row of the recovery table;
- `Journal::atlas` charts an open journal from what its scan verified;
- `Atlas::scan` charts a closed directory from its slot tables alone,
without opening or repairing it, for an injector that damages bytes
before the next boot;
- `last_batch`, `starts_batch` and `regions_in` give the batch
boundaries and map damaged bytes back to the regions they reach.
tests/atlas.rs checks moonpool#289's acceptance: the scan of a closed
journal equals the open journal's chart, damaging each charted entry
gets it reported at its index (corrupt, or ambiguous in the last batch),
and damaging it together with its slot gets a double fault. A seeded
loop aims damage the way recovery decisions need it: part of the last
batch, an entry beside its own slot, both copies of a twin, a run of
slots. It predicts the verdict from the regions hit and checks the
reopen against it, then checks that a second reopen finds every repair
durable. 2,000 seeds are green and reach every verdict (418 refusals,
254 of them double faults, and 398 ambiguous batches); the default
run is 150 seeds.
Refs #289.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015RwKdSwzjMSg5xgAdParyr
… land The simulator is layout-blind: a random storage fault hits whatever sector an operation touches, and most of a preallocated file is zeros nobody reads. The eligibility mask can only veto a sector. A FaultFocus lets a harness that knows its layout say how likely: a weight per byte range of a file, plus a background weight for the rest of that disk. - The probability of every family rolled per sector or per operation is multiplied by the weight of the sectors it would hit: read and write corruption, read and write EIO, phantom writes, sync lies, and the damaging crash outcomes (their bands scale within the one roll, capped at the whole roll). A weight of 0 makes a sector immune. The mask still vetoes first, and a weight never revives a family that the configuration leaves at zero. - A misdirected write honours only the immunity: its offset draw depends on the configured rate alone, so weighting it would move a draw. - Every roll is drawn whatever the weights: a focus changes which faults fire, never which draws decide them. - SimStorageProvider::focus_faults sets it from process code, scoped to that process's disk. The mask and the targeted injections are not reachable from a running simulation; this is. SimWorld::set_fault_focus does the same from a hand-driven test. A focus survives its process's crash and is cleared by a wipe of its storage. A neutral focus is checked to be a no-op: the same seed produces the same faults with or without it. Tests also check that a saturating spot on an immune background loses exactly that sector at every crash, and that write corruption lands only on the focused sectors. Book: the storage-faults chapter's "Aiming Faults" and the fault reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015RwKdSwzjMSg5xgAdParyr
A third crash-loop model, Aimed, runs moonpool's full physics. After every write it hands Journal::atlas to the disk as a FaultFocus: slots weighted 8, entries and twin copies 4, the preallocated zeros 0.1. The crash physics then damage identifiers and live entries instead of zeros. The guarantee is the harsh model's: a read never returns wrong data. A crash can only damage the sectors dirty at that moment, so the focus re-weighs a small set, but the gain is real. On 250 seeds, damage reported against acknowledged data (corrupt, ambiguous and refused) rose from 40 to 67: refusals from 1 to 4, acknowledged ambiguous entries from 15 to 36. The test compares both models on 120 seeds (15 to 26) and asserts that aiming raises the damage. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015RwKdSwzjMSg5xgAdParyr
A storage format that knows its on-disk layout can now describe it
without depending on the simulator: a LayoutRegion is a path, a byte
range and the format's own kind label ("journal slot", "superblock",
and so on). It lives in moonpool-core as plain data, so any storage
crate can produce it.
FaultFocus::layout (moonpool-sim) weighs a list of LayoutRegions by
kind. This is how a harness aims the simulator's random faults at a
format the simulator knows nothing about. moonpool-journal's map is the
first producer; a second layout only has to list its regions.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015RwKdSwzjMSg5xgAdParyr
…tRegion The atlas is the journal's layout, not a general one, so its names now say so: - Atlas becomes JournalAtlas and Region becomes JournalRegion; - the module is journal_atlas.rs, and the tests move to tests/journal_atlas.rs. Its Extent type is gone. Each charted region is now a ChartedRegion: the JournalRegion plus a LayoutRegion whose kind is JournalRegion::kind() (the SLOT, ENTRY, HEADER and META labels). JournalAtlas::layout lists them for FaultFocus::layout, and locate replaces extent. The aimed crash loop now builds its focus through FaultFocus::layout instead of walking the regions by hand. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015RwKdSwzjMSg5xgAdParyr
A replicated system survives disk damage only while some replica keeps
a clean copy of every record. Random faults drawn independently per disk
eventually hit every copy of one record, so a harness had to keep a
cross-node ledger to keep a run winnable. The simulator knows the
topology, so it can guarantee this by construction instead.
- LayoutRegion (moonpool-core) gains `stripe`: the replicated record the
bytes hold, as a key every replica's copy shares (a Paxos slot, a page
number). `None` marks node-local bytes.
- SimStorageProvider::publish_layout lets a process describe its own
disk; a wipe clears it.
- SimulationBuilder::replicated_storage_faults(ReplicatedFaults) draws a
FaultPattern per seed over the domains at a chosen DomainLevel:
- minority: only a few domains take damage, anywhere on their disks;
- helical: every domain does, but stripe s only in the domains s mod Z
rotates to; node-local and unpublished bytes are damaged only in the
domains drawn for them;
- spared: fewer than two domains, so nothing inside the topology is
damaged.
A record loses copies in at most `tolerance` domains (default 1,
clamped below the domain count), and so does node-local data.
- The helix is TigerBeetle's, keyed by record instead of file offset, so
it holds where replicas write records at different offsets.
- It is a weight of zero where damage may not land, composes with a
FaultFocus and the eligibility mask, and is inert without storage
chaos. It draws after every other per-seed draw, so opting in shifts
no other surface's sample.
- Not covered: disk failure, wipes, and lost unsynced directory entries.
- SimStorageProvider::fault_pattern tells a process which pattern its
seed drew.
Tests:
- four replicas in three zones lay out 24 records at different offsets
and take crash damage at a 50% rate; over 40 seeds no record (and no
node-local data) loses copies in two zones, a helix reaches every
zone, and a minority stays in its own;
- a wipe forgets the layout;
- the builder draws a pattern every seed of a three-zone cluster, and
none without storage chaos;
- unit tests cover the rotation, a sector holding two stripes, node-local
bytes, the tolerance clamp and the single-domain case.
Letting the helix damage every stripe everywhere turns the first test
red at seed 1. Book: the storage-faults chapter's replicated fault
patterns, and the fault reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015RwKdSwzjMSg5xgAdParyr
Owner
Author
|
CI note on I don't think it comes from this PR:
No fix exists for it yet. The push of Generated by Claude Code |
The static helix damages every domain at once, each on its own slice of the records. A rolling turn damages one domain at a time, anywhere on its disks, and moves on only once that domain has recovered, so each domain can be hit harder and recovery itself is under test. - FaultPattern::Rolling: the turn stays on a domain while it holds damage and moves to the next domain in order once the damage is repaired. Repair is read off the disk: every sector a random fault damaged has been rewritten, truncated away or deleted, or is no longer inside a region its process publishes. A domain holding no damage passes the turn on when another domain's disk is up for a fault, so an idle domain never stalls the rotation; one that never repairs does. With tolerance > 1 the window spans that many consecutive domains. - The disk image tracks damaged sectors (a crash's lost, torn or latent sectors, a lost synced write, phantom and misdirected writes, planted corruption); a write, truncation, delete, wipe or republish triggers a re-read before the turn next moves. - The static helix is renamed FaultPattern::Striped; each seed draws minority, striped or rolling. - ReplicatedFaults::group(name) scopes a pattern to one process group; replicated_storage_faults is called once per group, each with its own pattern, turn and records. Without a group it covers the whole topology. Processes outside every covered group keep plain storage chaos. The domain level (machine, zone, datacenter) stays per config. - SimWorld::fault_turn(ip) names the domains holding a rolling turn; SimWorld::fault_pattern takes the ip whose group it asks about. Tests: - the turn holds on a damaged zone, spares the next one, and moves on once the replica is rewritten in place; a truncation and an unpublishing republish free it too; - two groups over the same zones hold damage in different zones at once; - under every pattern no record loses copies in two zones over 40 seeds; - the builder covers only the named group. Mutations: dropping the damage clear on write turns the repair test red, and so does ignoring the window's damage. The first one also caught truncate-on-open skipping the re-read, now fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015RwKdSwzjMSg5xgAdParyr
This was referenced Oct 5, 2026
Closed
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 simulator's storage faults don't know the layout or the replication. A random fault hits whatever sector an operation touches; most of a preallocated journal segment is zeros nobody reads. The cases recovery has to judge come in pairs: an entry and its own slot, or both copies of a header or of the metadata. Under uniform damage they almost never happen. Across replicas, independent random damage eventually hits every copy of one record and makes a valid run unwinnable, so harnesses keep their own cross-node ledgers to prevent it.
The motivation is downstream. paros wants to drop its modelled storage world and run on moonpool's disk directly (PierreZ/paros#176). That needs moonpool's faults to land where they matter and to keep every record recoverable, both decided inside moonpool. paros should only describe its layout.
What
Four layers, each knowing only what it must:
moonpool-core:LayoutRegion. A storage format describes its on-disk layout as plain data: a path, a byte range, a kind label, and an optionalstripe. The stripe is the replicated record the bytes hold, as a key every replica's copy shares (a Paxos slot, a page number). It doesn't depend on the simulator.moonpool-journal:JournalAtlas(closes #289). It maps every region recovery reads,JournalRegion::{Header, Slot, Entry, Meta}, each one as aLayoutRegion.Journal::atlas()charts an open journal;JournalAtlas::scan()charts a closed directory without opening or repairing it.last_batch,starts_batch,locateandregions_inround out the API.stripeasNone: its caller knows what the tags mean (LayoutRegion::striped).moonpool-sim:FaultFocus. It sets a weight per byte range of a process's disk, plus a background weight.SimStorageProvider::focus_faultsis reachable from process code;FaultFocus::layout(regions, weight_by_kind)builds one from any layout.moonpool-sim: replicated fault patterns.SimStorageProvider::publish_layout(regions)describes a disk.SimulationBuilder::replicated_storage_faults(ReplicatedFaults::new(level).group(name))covers one process group, at one domain level (machine, zone or datacenter). Call it once per replicated group: each gets its own pattern, turn and records. Without.group(..)it covers the whole topology; processes outside every covered group keep plain storage chaos.sonly in the domainss mod Zrotates to; node-local and unpublished bytes are damaged only in the drawn domains;tolerancedomains at once (default 1), and so does node-local data, by construction with no ledger.SimStorageProvider::fault_patterntells a process what its group drew;SimWorld::fault_turn(ip)names the domains holding a rolling turn.Evidence
DoubleFault.Aimedcrash-loop model, with the focus fed fromjournal.atlas().layout()): damage reported against acknowledged data went from 40 to 67 on 250 seeds. The guarantee is unchanged: a read never returns wrong data.Behaviour change
A crash on a vetoed (mask-ineligible) sector used to always keep the old bytes; it can now keep the new ones too. Both are legal.
Noted, not changed
the_eligibility_mask_shields_the_sectors_it_namesprobably checks nothing on about half its seeds:fast_local()reverts the unsynced file length on 50% of crashes, which leaves no sectors to judge. The new tests pin that knob.Checks
cargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warningscargo nextest run --workspace(1,281 passed) andcargo nextest run -p moonpool-sim --no-default-features(643 passed)--no-default-features: clippy and the wasm32 checkcargo docwith no new warnings, andmdbook build. The book covers aiming faults, the replicated fault patterns, the fault reference, and the journal's layout chapter.🤖 Generated with Claude Code
https://claude.ai/code/session_015RwKdSwzjMSg5xgAdParyr