Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.

test: executable repro for torn-shutdown corruption, plus a loaded-index-growth guard - #179

Merged
pathscale merged 2 commits into
masterfrom
fix/loaded-index-growth
Aug 1, 2026
Merged

test: executable repro for torn-shutdown corruption, plus a loaded-index-growth guard#179
pathscale merged 2 commits into
masterfrom
fix/loaded-index-growth

Conversation

@pathscale

Copy link
Copy Markdown
Owner

Two tests distilled from the four store corruptions agencyzero took on 2026-08-01.

test_store_survives_torn_shutdowns (ignored, the repro). Kills a writer child mid-write five times, then loads and scans the store in-process. It fails today in the two ways production failed:

  • the scan returns a phantom all-zero row (id: "\0\0\0\0\0\0\0\0") — an index link published for data that never got written, the same debris agencyzero pulled out of its store;
  • or the next load dies inside data_bucket page parsing (parse_general_header).

Root cause, as far as the evidence goes: pages are written in place with no atomicity across one operation's data-and-index steps (the PersistenceTask Drop comment says as much), and everything is read back through rkyv::access_unchecked, so torn bytes don't fail at load — they load as garbage whose wild relative pointers SIGBUS in whatever walks them later. Any abrupt process end (crash, SIGKILL, or a consumer quitting without wait_for_ops) can tear the store, and each SIGBUS then tears it further: that cascade is what ate agencyzero's store four times in one day.

Run it with: cargo test -- --ignored test_store_survives_torn_shutdowns (fails in ~4s). Un-ignore it the day the engine gets crash-consistent writes (WAL / shadow paging / ordered fsync) or validated-and-refusing loads (bytecheck at the parse boundary + page checksums). Those are the fix directions; both are engine-level projects rather than spot patches, which is why this PR ships the repro rather than an attempt.

test_primary_index_grows_on_a_loaded_table (passing, a guard). The dead production tables shared a signature: primary.wt.idx frozen at exactly the size it was loaded with (65536 in one, 229376 in the other) while .wt.data kept growing. Plain build-close-load-append does grow the index correctly, so this pins that invariant with exact-id-set assertions across a further reload, in the schema shape that died (String uuid primary key, duplicated String secondary, ~1K payloads).

Preserved forensic material (poisoned stores, before/after copies) lives at ~/code/worktable-idx-growth-evidence-20260801/ with the analysis in ~/code/HANDOFF-worktable-idx-growth.md.

meh added 2 commits August 1, 2026 17:30
…owns

Two tests from the 2026-08-01 agencyzero store corruptions.

loaded_index_growth (passing, a guard): build a store, close it, load it,
and append until the primary index must grow past the size it was loaded
at, then hold every row addressable across one more reload. The production
stores died with their primary.wt.idx frozen at the loaded size while
.wt.data grew, so growth-on-a-loaded-table stays pinned.

torn_shutdown (ignored, the repro): kill a writer child mid-write five
times, then load and scan. Fails today two ways, both observed in
production: a phantom all-zero row comes back from the scan, or the load
dies inside data_bucket page parsing. The engine writes pages in place
with no atomicity across an operation's data-and-index steps, and reads
everything back through rkyv::access_unchecked, so an abrupt death (crash,
SIGKILL, quit without wait_for_ops) leaves bytes that load as garbage and
blow up later as SIGBUS. Un-ignore when the engine gets crash-consistent
writes or validated loads. Run it with:
cargo test -- --ignored test_store_survives_torn_shutdowns
The passing control for the torn-shutdown repro: the same schema taken
through forty sessions of a few appends each, every one drained and closed
cleanly, then held to the exact id set on a final scan. It passing narrows
the corruption to abrupt deaths: clean generational aging alone does not
drift, so a store that dies carried a tear from a kill, a crash, or an
undrained exit somewhere in its history.
@pathscale
pathscale merged commit 997174b into master Aug 1, 2026
3 checks passed
@pathscale
pathscale deleted the fix/loaded-index-growth branch August 1, 2026 10:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant