Repository navigation
#765 Retire the OLC B+Tree defect generators: make it detectable, then fix the three defects that surfaced - #768
Merged
Merged
Conversation
… defect it had been reporting all along The first thing S0 did was produce evidence that the premise was too kind. The checker was not merely unable to fail — it had been detecting a real defect on every single run and the result was being thrown away. Five consecutive runs of OlcBTreeStressTests emitted two to three separator violations each and reported PASSED each time, and one of those violations was byte-identical across all five: parent=99 slot=27, separator=12322 sitting above a leaf whose first key is 12321. That one reproduces with ONE thread and ONE key range. No concurrency, no contention, no scheduler luck. Move chose the leaf it would INSERT into with OptimisticDescendToLeaf's default followRightLink: true, and that walk is a reader's tool — it hops right until the key falls inside a leaf's actual contents, which is how a reader still finds an existing key after landing left of a concurrent split. A key being newly inserted is in no leaf at all, so the walk cannot terminate on a match and instead runs one leaf PAST the one whose separator range owns the key. Move then inserted there, below that leaf's separator. The insert path has passed followRightLink: false since forever and says why at the call site; Move is the hand-written copy that never received it, along with both range checks Insert accumulated across #297, #679 and #740. Reads survived it, which is exactly why it stood for so long: the same right-walk that causes it also recovers from it, so TryGet finds every key and only the structural check notices. The insert path does not recover. The damage was one stale separator away from being a lost key, and in the meantime it made the checker look like it was crying wolf — which is the actual mechanism by which this subsystem went 160 days without a working instrument. So the guards are stated once rather than copied a fifth time. KeyAboveLeafUpperBound is the upper-bound half that was already inline on the OLC insert path, now named; KeyOutsideLeafAuthority pairs it with the existing KeyBelowLeafLowerBound; and Move, MoveValue and the general insert path all ask the same question. Both halves route through a new devirtualised CompareKeys so the guards stop paying an interface call per insert on a path whose surrounding code compares directly. Rule IXW-04 records the invariant and IXW-03 loses its "Move.cs has no lower-bound guard at all" gap line. Measured, because a guard stronger than its invariant is what #740 was: zero violations in ten consecutive runs, against two to three per run before. And it removes work rather than adding it — same-leaf moves stopped being misrouted down the two-leaf path, taking Stress_MoveSameLeaf from 12 optimistic restarts and 109 pessimistic fallbacks to 0 and 0, and Stress_MoveCrossLeaf from 1676/555 to 1346/482. With the tree correct, TryCheckConsistency is gone and CheckConsistency throws at all nine sites. Reverting only the Move fix now reddens seven tests: the four new ones and three existing stress tests that had been reporting PASSED for months. The nightly's bare continue-on-error is replaced by bench/aws/nightly-known-red.txt, an allowlist where every entry carries an issue. A failure not on the list fails the job; an allowlisted test that passes emits a warning rather than a failure, because these fixtures are flaky and one green run proves nothing, but a name that stops appearing is the cue to delete the line. The old hardcoded known-red prose in the summary step is deleted rather than left to drift alongside it. Both branches of the new step were exercised against synthetic trx before landing. Finally the race harness stops retiring a scenario on its first deadline — it now tolerates three and says so when it stops — and stops reporting the word DEADLINE. It samples the tree's counters twice a second apart and classifies: STUCK when nothing moves, SPINNING when only WriteLockFailures moves, RESTARTING when restarts or fallbacks move, SLOW otherwise. That distinction is the one the old label could not make, and it immediately contradicted the story on #738: a forced deadline reports 2.86 million write-lock failures in one second with restarts, fallbacks, splits and entries all frozen. That is lock-acquisition livelock, not the restart-bound burn #738 currently describes. Full suite: 5,123 passed, 4 failed — all four the documented quarantine reds of #400 and #389, none in indexing.
…nd prove each one can fail The checker asserted chain linkage, leaf depth, separators and HighKeys. Everything it looked at, it looked at through GetFirst and GetLast, so four properties passed underneath it untouched. Intra-node ordering is the one that matters most and was checked nowhere. NodeWrapper.CheckConsistency compares each item against the PARENT separator and pins only the endpoints; the chain checks read a node's first and last key and nothing in between. A leaf holding [1, 9, 3, 5, 12] satisfies every assertion in the file, and a vectorised search over it answers "not found" for keys that are present, non-deterministically by which half it lands in. That is #297's symptom with no instrument able to say the node was the reason. The other three are the structures disagreeing with each other. Descent-reachable leaves versus chain-reachable leaves: separate structures, separate maintaining code, and every defect in this subsystem's history has been one of them disagreeing with the other, yet each individual check walked one of them. EntryCount versus the materialised cardinality of the chain, because EntryCount is the number the tests assert on most often, so drift both hides a lost key here and manufactures a phantom failure somewhere else. And latch residue at quiescence, since a leaf still locked after every worker has joined is a write path that returned without unlocking, which is what #695 was, and the next writer to reach it spins forever. The walk caps are failures now instead of silent truncations. Three walks were written to stop at a million nodes and then render a verdict on the part of the tree they had seen; a tree that trips that bound is cyclic or impossibly large, and PASSED is the one answer that cannot be right. Every one of these ships with a mutant, because the entire lesson of S0 is that a green check and a check that cannot go red are indistinguishable from outside, and adding four more assertions without proving they bite would be repeating the mistake with more code. Each mutant builds a healthy 2,000-key tree, asserts the validator is silent on it, breaks exactly one thing through NodeWrapper's ordinary mutators, and requires that validator's own message. Rules IXS-04 and IXS-05 record the two new invariants; DiagnosticRoot and DiagnosticLeafChainHead exist only so those mutants can author a violating tree, and they are read-only handles, so they widen visibility rather than capability. Add_Disjoint and Remove_Disjoint now call CheckConsistency too. Both asserted only that every key ANSWERS, which is a different question from whether the tree is sound, and the gap between them is exactly where a leaf sits correctly chained, correctly counted, and reachable only by the B-link right-walk. Measured over 25,701 race-harness iterations: zero structural violations, so the four new invariants hold everywhere the suite reaches. What the harness did surface is the defect underneath #739 — Remove_Merges failed five times with EntryCount=1201 expected=1200, chainCount=1201, removeReturnedFalse=1, survivingRemovedKeys=[378]. The chain and the counter agree with each other; the key is genuinely still present and Remove reported false. That is a false not-found on the remove path, not corruption, and no structural check will ever catch it — worth knowing before S5 goes near merge. Full suite: 5,128 passed, 3 failed, all three the documented quarantine reds of #400 and #389.
Two changes, both aimed at diagnostics that distort what they report. BTree.Move.cs held 31 WriteUnlock calls and zero AbortWriteLock. The two differ in one bit of behaviour and a great deal of consequence: WriteUnlock bumps the node's version, which tells every optimistic reader and writer holding a snapshot that their snapshot is stale, so they restart. After a real mutation that is exactly right. After a version validation that failed, a key that turned out to be absent, or a full-leaf bail to the pessimistic path, it is a lie — and the threads it restarts go around and contend for the same latch again. #679 named those spurious bumps as the measured cause of its restart storm. Twenty-one of the thirty-one release a latch having written nothing at all, and those are now AbortWriteLock. The remaining ten each follow a leaf mutation or a VSBS buffer write. That includes the res == -1 bails, where the leaf's own items are unchanged but RemoveFromBuffer has already run: a bail that has written to a buffer is not a no-op, and this is not the place to be clever about it. Measured over five runs per side, medians, on the metric this actually targets — optimistic restarts, which unlike spin counts are not affected by how expensive a spin iteration is. Every fixture that exercises Move improved: MoveValueTailConsistency 932 to 715, EnumerationDuringMutation 924 to 725, ContentionSplit_TreeConsistency 7975 to 6423, MixedReadWrite 487 to 429, MoveCrossLeaf 2004 to 1797. That is 10 to 23 percent fewer restarts. The only two fixtures that did not improve, ConsistencyCheckInterleaving and ContentionSplit_MixedReadWrite, are the two insert-only workloads that never call Move, and their small increases are inside the run-to-run band. Pessimistic fallbacks move the same way, 1235 to 1039 and 126 to 107 on the two heaviest. The second change is the write-lock spin counter. Interlocked.Increment(ref _writeLockFailures) sat inside both spin phases, so every spinning thread issued a locked read-modify-write to the same shared field on every iteration, on a cache line the spinners are already fighting over. Phase 2's loop is unbounded, so a long wait turns that into millions. The race harness's new deadline sampler caught it directly: 2,861,200 increments in ONE second on a single iteration, with restarts, fallbacks, splits and entry count all frozen. A diagnostic counter generating the cross-core traffic it exists to report. Spins are now tallied in a local and published once per acquisition, in SpinWriteLock and SpinWriteLockOnSmoPath alike. One caveat worth stating plainly, because the obvious reading of the numbers is wrong. The published total still counts spin iterations, but it is NOT comparable across this change: removing an atomic from the loop body makes each iteration cheaper, so more of them fit in the same wall-clock wait. Measured, the counts rose — ContentionSplit_TreeConsistency 48454 to 51066 — while the wall time did not, which is the signature of a faster spin rather than more contention. Treat pre- and post-change spin counts as different units. Wall time across these fixtures is flat, within noise either way. That is expected: they are dominated by the workload, not by latch contention, and they are the wrong instrument for a contention micro-change. S4 exists to get the right one. Full suite: 5,128 passed, 3 failed, all three the documented quarantine reds of #400 and #389.
…hrough the shared predicate, and audit the other thirteen sites S0 stated leaf authority once and applied it to the four Move and MoveValue sites that had no guard at all. This finishes the sweep. InsertIterative's B-link move-right loop was the fourth longhand copy of the upper-bound predicate: count > 0, a valid right sibling, and key >= HighKey. It is now literally while (KeyAboveLeafUpperBound(...)). The pessimistic path answers that question differently from the optimistic one — it walks right until the leaf owns the key instead of restarting, because mid-SMO it has no restart point to go back to — but the question is identical, and a question asked in four places is a question that will eventually be asked four different ways. That is the whole thesis of this feature, and #740 is what it looks like when it happens. The remaining sites were audited rather than changed, because they are already sound and adding a predicate to them would only over-restart. All fourteen leaf writes: the four in Move and MoveValue call KeyOutsideLeafAuthority; the OLC general insert path calls both halves; InsertIterative's three InsertLeaf calls are covered by the move-right loop above and KeyBelowLeafLowerBound below; the two PushLast and two PushFirst fast paths answer both bounds structurally rather than by predicate — PushLast requires the leaf to be genuinely rightmost, where no upper bound exists, plus key strictly above its last, and PushFirst requires genuinely leftmost, where no separator routes to it; and the two new-root inserts have no siblings and no separator, so the question does not arise. IXW-04 records the audit with its date so the next person can tell an audited site from an overlooked one. BTree fixtures green. The full suite shows one extra red beyond the usual three, Calibration_Reasonable, which is a wall-clock calibration test that ran while the S4 benchmark was saturating all 32 threads on this box. Re-verified on a quiet machine before the branch is handed over.
…ecords them, and take the first baseline they have ever produced Four concurrent B+Tree benchmark classes existed and had never produced a single recorded number. benchmark/history holds four runs across 19 classes, and the only B+Tree entry in any of them is BTreeMicroBenchmarks — six single-threaded results, last taken 2026-07-19 on a CI Xeon, before PR #737. Every scaling claim this design was justified by has therefore been unfalsifiable since it was written. The cause was one word. bench/aws/benchmark.sky.yaml maps the default profile to --allCategories Regression, and all 19 recorded classes carry "Regression". The concurrent classes carried BTree, Concurrency and BTreeMedium, and btree-medium is a profile that has to be dispatched by hand. Nobody ever did. That is the same shape as the [Explicit] finding in S0 — a label that quietly removes something from the only tier that runs it — and it is why this feature keeps finding instruments rather than defects. One representative benchmark per class is promoted: ConcurrentInsert_Random, ConcurrentDelete_Random, Mixed_95Read_5Write, SecondaryUpdate_HotLeaf and ConcurrentLookup_RandomKeys. Verified by running --allCategories Regression --list flat and confirming all five are selected, because adding a second marker nobody checks would be the same mistake with a different word. ConcurrentInsert_Monotonic is deliberately left out, and that is a measurement decision rather than an oversight. It inserts a new key from a shared counter on every operation and never resets, so the tree grows by 50,000 keys per iteration and keeps growing through warmup — iteration 5 measures a materially taller tree than iteration 1. That is drift, not noise, and it shows: error half-widths of 648 ns on a 1,087 ns mean at 4 threads and 2,895 ns on a 2,948 ns mean at 16, against 3.76 ns on 196 ns for its sibling. A metric whose error bar is its own magnitude produces alarms nobody can act on. The comment on the method says what would fix it. The baseline itself is in claude/research/Indexing/olc-btree-baseline-2026-08.md. Reads are genuinely good: ConcurrentLookup_RandomKeys goes 161.46 ns to 16.73 ns from 1 to 32 threads, a 9.65x speedup with error bars under a nanosecond. Writes plateau early and then regress — Insert_Random peaks at 2.75x on 4 threads and falls back to 1.30x at 32, Delete_Random the same. The two single-hot-leaf workloads go backwards outright: SecondaryUpdate_HotLeaf is 3.3x SLOWER at 32 threads than at 1, and Monotonic 8x slower, on the benchmark whose own docstring says contention splits distribute the load. The cross-CCD story does not explain it. This is a 7950X and 32 threads spans both CCDs, but ConcurrentLookup_RandomKeys keeps improving from 16 to 32 threads straight through that same boundary. Reads scale across it and writes collapse, so the differentiator is contention on a shared leaf, not the interconnect.
…vershot The race harness found this once S1 gave it instruments. Over 25,701 iterations it produced six Remove-NotFound events, and the branch counters put all six on the same branch: the general descent concluding keyIndex < 0. In every one of the six the key was BELOW the first key of the leaf the descent stopped at — key 378 on a leaf whose first key is 381, key 474 on one starting at 475, key 88 on one starting at 89 — on leaves holding 14 to 21 entries, which is the signature of a leaf a concurrent merge or borrow has just shifted keys out of. The right-walk only ever tests the upper side: is the key past this leaf. It exists to recover from a descent landing too far LEFT after a split, and it can only travel right. So overshooting is unrecoverable by construction — land one leaf too far right and key <= leaf.lastKey is trivially true, the loop declares itself conclusive, and every caller reads that as definitively not in the tree. A merge moving keys leftward between the separator read and the leaf read is all it takes. What makes this hard to see is that the tree is not damaged. EntryCount and the leaf chain agree with each other, the key is present and correctly chained and reachable, every structural validator passes. The only thing wrong is the answer. That is why S1's four new invariants found nothing while the harness underneath them was failing five times per run. The obvious guard is the #740 trap in a new place: restarting whenever key < leaf.firstKey. That band is legitimate for a genuinely absent key, because removing a leaf's first key raises its minimum above the separator that still routes to it, and a guard that restarts there never terminates. KeyBelowLeafLowerBound is the predicate that already draws that line correctly, against the previous leaf's HighKey rather than this leaf's first key, so an absent key in the residue band still answers NotFound and only a key that provably lives further left restarts. It is the same predicate the four write sites use, now on the read path — which is the point of having stated it once. Measured. Before: 25,701 iterations, 17 failures, of which 6 were these. After: 94,854 iterations across two runs of 180 and 240 seconds, ZERO Remove-NotFound events — the detail log is never even created — and 2 failures total, both deadlines. Iteration throughput rose 63 percent in the same wall time, because those failures had been costing deadline stalls. Recorded as IXS-06. #297 is the same descent reaching the same wrong conclusion on TryGet rather than Remove, so it goes with it. What remains in the harness is #738 and only #738: one DEADLINE/STUCK and one DEADLINE/RESTARTING across the two runs. No deterministic regression test ships with this. It needs a concurrent merge to move keys left inside another thread's descent window, and I would rather say that plainly than write a test that passes for the wrong reason — the mistake I made on the Remove twin in PR #766. The evidence is the invariant plus 94,854 iterations. Full suite: 5,128 passed, 3 failed, all three the documented quarantine reds of #400 and #389.
…otched first attempt The guard added in the previous commit sits on the lookup MISS path, and I claimed nothing about its cost because my first measurement was invalid. I had already committed the change before benchmarking, so `git stash push` had nothing to stash and the supposed "before" run was the same code as the "after" run. That pair is worthless as a comparison and I am not going to pretend otherwise. It is worth something else, though: two runs of identical code varied by up to 18 percent on this box. That is the noise floor, and it is larger than the effect being measured, which is exactly why a single before/after pair was never going to settle this. Redone with three runs a side and the guard genuinely removed in between. BTreeMicroBenchmarks.Lookup_Miss goes from a 197.8 ns median to 217.4 ns, and the two sets do not overlap at all — the worst with-guard run, 209.4 ns, still beats the best without, 198.2 ns. So it is about +11 percent, roughly 20 ns, which is one extra GetItem(0) and one compare on the miss path. Lookup_Hit is untouched, and that is mechanical rather than lucky: the guard lives inside the keyIndex < 0 branch, which a hit never enters. That is a real price for a correct answer, not a free win, and IXS-06 now quotes it so nobody has to re-derive it. Twenty nanoseconds for one compare is more than it should be — most of it is the virtual BaseNodeStorage.GetItem call that S8 exists to devirtualise, so the number should come down without touching the guard. Whether 11 percent on a pure-miss microbenchmark is worth eliminating a false not-found on both Remove and TryGet is a judgement call, and it is Loïc's, not mine. The alternative is a tree that occasionally reports a present key as absent, which is #297 and #739.
…ur-leaf fast path There was no Move benchmark anywhere in this project. That is why #221 sat open since February claiming a 40-50 percent win nobody could check, and why the assessment had to re-derive the figure by reading source. Move is a compound operation with its own OLC protocol — two descents, a same-leaf fast path, a two-leaf path with ChunkId-ordered locking — and not one line of it was measured by anything. So the benchmark comes first. Move_SameLeaf and Move_CrossLeaf both toggle a key to a vacant slot and back, so the tree returns to its starting state every two invocations and the measurement cannot drift the way ConcurrentInsert_Monotonic does. GlobalSetup punches two holes in the gapless 1..10000 pre-fill to create those vacant destinations — without them Move finds the key occupied, returns false immediately, and the benchmark times a rejection instead of a move. Both are in the Regression category, so they enter benchmark/history from now on. Then the change itself. Move descended from the root twice: once for oldKey, once for newKey, and only then compared the two leaf ids to discover they were the same. The second descent is unnecessary whenever the leaf already in hand demonstrably owns newKey's range, and that test is the exact complement of the leaf-authority predicate S0 introduced — newKey at or above this leaf's first key and below its HighKey. It can only ever return the same leaf the general path would have picked, because it concludes only when both bounds hold on a version-validated read, and the authority check under the lock re-asks the identical question. A wrong answer costs a restart, never a misplaced key. Measured, three runs a side, non-overlapping in both directions. Move_SameLeaf goes from a 310.4 ns median to 267.0 ns, a 14.0 percent improvement, and the worst run with the fast path still beats the best run without. That is the 13-17 percent the assessment predicted, not the 40-50 percent the issue claimed. Move_CrossLeaf goes the other way: 340.7 ns to 394.1 ns, 15.7 percent SLOWER. When the fast-path test fails it is pure added cost, and the descent happens anyway. I am not going to bury that. The change is a net win only where same-leaf moves dominate, which is the workload #221 was filed about — a positional or spatial index shifting an entity to an adjacent slot. On a cross-leaf-heavy workload it is a net loss, and the numbers to make that call are now both recorded and reproducible, which they were not before today. Two other S8 items are NOT done, and one of them should not be. The assessment proposed propagating a cached leaf flag through GetChild; that is unsafe, and the code says so at the call site — OLC readers call GetChild on a parent whose version is not yet validated, so dereferencing the child to read its leaf bit can crash before validation can signal a restart (#297). Deriving it from Height instead is rejected by an equally explicit comment on Root, for the same issue. Devirtualising BaseNodeStorage is real but it is a generic-parameter refactor of the whole BTree type, not a cheap win, and it is what would pay back most of the 20 ns the #739 descent guard costs. Full suite: 5,128 passed, 3 failed, all three the documented quarantine reds of #400 and #389.
…on answer, taking the same-leaf Move win to 20 percent KeyAboveLeafUpperBound read the right sibling before comparing against HighKey. Both conjuncts are required so the result is identical either way, but the overwhelmingly common answer is "no, the key is in range", and in that case the old order paid a GetNext it never needed. Comparing first short-circuits one virtual BaseNodeStorage call out of the hot answer. Measured on the Move benchmark added in the previous commit, three runs a side throughout. Move_SameLeaf was 310.4 ns before #221, 267.0 ns with it, and 248.2 ns with this reorder on top — 20.0 percent below baseline, and each of the three stages is separated from the next by more than its run-to-run spread. Move_CrossLeaf is unchanged by the reorder at 392.5 ns, so the 15 percent cross-leaf cost of the fast path stands and I am leaving it visible rather than averaging it away. The remaining miss cost is roughly three node reads before the descent happens anyway. One of the three, the GetCount > 0 guard, is provably redundant at Move's call site because the leaf demonstrably holds oldKey — but removing it there means hand-writing a fourth variant of the predicate at one call site, which is the exact generator this feature exists to retire. Five nanoseconds is not worth reopening that door. The reorder also sits on the OLC general insert path, which asks this question on every insert, so the rest of the micro suite was re-run twice as a regression check: Lookup_Hit 178-179 ns, Lookup_Miss 207-231, Insert_Sequential 213-222, Insert_Random 259-270, Delete_Reinsert 483-502, SequentialScan_100 147-148. All inside the band established earlier, with Insert_Random arguably better and nothing worse. Full suite: 5,128 passed, 3 failed, all three the documented quarantine reds of #400 and #389.
…ine classifier inventing a STUCK Two findings from the S7 measurement pass, one in the tree and one in the instrument I built to look at it. The instrument first, because it produced the only STUCK sample I had. DiagnoseDeadline read the counters and concluded "nothing moved, therefore nothing is being attempted" without ever asking whether the iteration was still running. Wait timing out and the body finishing are not mutually exclusive: a body that completes a millisecond after the deadline leaves every counter frozen for the whole sample window, and the classifier read that as a lock cycle. That is the same mistake as the old "HANG" label wearing better clothes, and this harness has already sent five #738 hypotheses chasing a cycle that was never there. It now checks iterTask.IsCompleted first and reports LATE — a budget too tight for a loaded box — before interpreting a single counter. Then the tree. Over 94,814 iterations the harness threw one NullReferenceException, in NodeWrapper.GetItem, from InsertLeaf via InsertIterative on the pessimistic insert path. The node dereferenced was default: relatives.RightAncestor, with a null storage. Both spill branches finish by rewriting the separator that routes between this leaf and the neighbour it spilled into, and they reach that separator through relatives.LeftAncestor or RightAncestor. Eligibility, though, was decided entirely from the LEAF CHAIN — GetPrevious/GetNext plus a sort-invariant check — and a chain neighbour is not necessarily a cousin under a shared ancestor. It can sit in a different subtree, and then the ancestor is default and the separator write dereferences null. Rare because it needs a full leaf whose chain neighbour has room AND lives across a subtree boundary; one occurrence in 94,814 iterations. The fix is to require the ancestor the branch is about to write through. Falling through to split is the documented alternative — the comment above that block already calls split range-self-contained — so this strictly narrows when a spill is attempted and never changes what a legal spill does. Validated on the same 420-second configuration that found it: 93,883 iterations, zero NullReferenceExceptions, and the two remaining failures are both DEADLINE/RESTARTING. The STUCK is gone as well, which is what the LATE correction predicted for a single early-iteration sample taken 30 seconds into a cold run. Micro benchmarks re-run twice as a regression check, since narrowing spill eligibility pushes work onto the split path: Lookup_Hit 185-195, Lookup_Miss 212-227, Insert_Sequential 220-242, Insert_Random 292-324, Delete_Reinsert 502, SequentialScan_100 150-180, Move_SameLeaf 261-267, Move_CrossLeaf 379-395. All inside the band established for this box, nothing systematically worse. On S7's actual question — build the crabbing fallback or not — the answer is still not yet, and the evidence for waiting is now stronger. What is left after this fix is exclusively RESTARTING, at 2 events in 93,883 iterations. There is no longer any measured STUCK to build a forward-progress fallback against. Full suite: 5,127 passed, 4 failed — the three documented quarantine reds of #400 and #389, plus ParallelSpawn_AllEntitiesReadableAfterCommit which passes 3 of 3 in isolation and belongs to the known flake band.
…under concurrency The guard added in 560a3fa is unsafe on the path I put it on, and CI caught it on the first run of this branch's nightly tier. KeyBelowLeafLowerBound reads leaf.GetPrevious() and then DEREFERENCES that neighbour for its HighKey. On the four write paths that call it the leaf is write-locked, so the neighbour id is stable and the read is safe. The descent is not: it is lock-free by construction, the id can be torn or point at a chunk a concurrent merge has just detached, and dereferencing it faults before any version validation can signal a restart. The process dies with no managed stack, which is why the symptom is "Test host process crashed" rather than an exception. That is precisely the hazard BaseNodeStorage.GetChild documents in its own comment — do not dereference the child here, the id can be torn, validation cannot save you — and I quoted that comment while rejecting a different proposal earlier on this same branch before walking into it here. Measured, ChaosStressTests.Light_2T_50E_NoDelete: 6 of 6 passing on main, 4 of 5 aborting with the guard, 4 of 4 passing with the call removed. The CI nightly tier hung on the same test and was killed by its own blame-hang timeout, which is how it surfaced. The defect the guard was fixing is not in doubt and is not reverted away: 6 Remove-NotFound events in 25,701 race-harness iterations, all on the general-descent branch, all with key below the landed leaf's first key, and zero in 94,854 with the guard in place. #739 and #297 go back to open. IXS-06 stays in the rule database, downgraded to UNBUILT, carrying the evidence and the reason the first enforcement failed — so the next attempt starts from the finding instead of rediscovering it. The next attempt should not use this predicate at all. The descent already follows a separator to choose each child, and that separator IS the key's lower bound. Carrying it out of the descent answers the question with no neighbour read whatsoever — cheaper than the reverted version and safe by construction rather than by luck. Full suite: 5,128 passed, 3 failed, all three the documented quarantine reds of #400 and #389.
…fails, not from what I guessed The first version of this file was populated from the workflow's old hardcoded prose and from reading QUARANTINE.md, and it was wrong in the way that matters: it named reds I assumed and missed one that was really there. The tier's first run on this branch reddened on LinearizabilityTests.ParallelOperations_AreLinearizable_Deep, which QUARANTINE.md lists under #400 and which I never saw locally because the _Deep variant is [Explicit] + Nightly and therefore only ever runs in this tier — every local full-suite run reports it Skipped. That is the allowlist mechanism working on its first outing: a red nobody wrote down is exactly what it is built to catch, and it caught one of mine. Now derived from the artifact rather than from memory. Added the three #400 entries and the #389 recovery oracle, each under a header carrying its issue. Worth noting for whoever reads this next: the same run also showed the tier does not complete. It aborted after two tests when blame-hang killed the host at its 300-second inactivity limit, and the trx it left behind held 2 results out of a tier that should run dozens. The verdict step then diffed those two partial results against the allowlist and rendered a verdict, which is a checker reporting confidently on incomplete data — the exact defect class this feature exists to remove, now sitting in the thing I built to remove it. Not fixed here; it needs the verdict step to detect an aborted run and say so instead.
…ished The verdict step's first real execution rendered a confident verdict on a tier that had aborted after two tests, and I only noticed because the answer it gave was wrong for an unrelated reason. When --blame-hang kills the host, vstest still writes a trx — a PARTIAL one, holding only what completed before the kill. On PR #768 that was 2 results from a tier that runs dozens. The step then diffed those two against the allowlist and reported an allowlist miss: a true statement about data that does not describe the tier, delivered with no indication that most of it never ran. That is a checker reporting confidently on incomplete input, which is the exact defect class this whole feature exists to remove, reproduced inside the instrument built to remove it. The pre-existing "Assert the tier actually selected tests" guard does not catch it either: it tests total == 0, and two-out-of-dozens sails straight through. So the verdict now answers "did this finish?" before it answers anything else. Two signals, both already present and neither previously read: RunInfo entries carrying an abort, a crashed host or the inactivity timeout; and the blame Sequence file, which records the running order and marks the test that never came back — naming the hang directly rather than leaving it to be inferred. On an aborted run it fails with that as the reason and does not diff the allowlist at all, because there is nothing meaningful to diff. Exercised against the actual failing artifact from run 31412378924 rather than a mock: it names the abort, the inactivity timeout, and Light_2T_50E_NoDelete as the test that never completed. The clean path and the new-red path were re-checked afterwards and still behave — known reds exit 0 with a stale-entry warning, an unlisted failure exits 1. The summary it writes says not to allowlist past it, because that is the obvious wrong response to a red like this.
…he allowlist I invented
The allowlist was the wrong design and I should have looked before building it. This repository already marks a known-bad test with [Category("Quarantine")] and documents it in test/Typhon.Engine.Tests/QUARANTINE.md. I added a second, parallel mechanism — a hand-maintained file of test names — without checking for the first, and then spent a CI round-trip discovering my copy was missing an entry. bench/aws/nightly-known-red.txt is deleted.
The tier's filter now excludes that category. Measured with --list-tests before changing it, because the comment above that line warns that widening the filter can stop NUnit honouring [Explicit]: 485 tests selected with one term, 477 with two, and OlcBTreeRaceStressTests — the [Explicit] one that matters — is still in the list. The eight it drops are exactly the tests QUARANTINE.md already tracks.
One of those eight is why this matters more than tidiness. ChaosStressTests.UltimateStress_AllSubsystems does not merely fail: it takes the test host down, which ABORTS the run and stops every other test in the tier from reporting. It does that on main too, so it is not a regression from this branch — it means this tier has never once completed, and the bare continue-on-error made the job green throughout. The previous run got 24 tests in before dying; the run before that, 2.
With the reds excluded rather than enumerated, everything the tier still runs is expected to pass, so the verdict step no longer diffs anything: any failure is news, and the message says the only supported way to silence it is to quarantine the test deliberately and write down the issue.
The abort detection stays and is now the first thing it does. Both paths were exercised against the real artifact from run 31415956653 rather than a mock — the aborted case names UltimateStress_AllSubsystems as the test that never came back, and the completed case lists the six failures individually.
This was referenced Aug 10, 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.
Implements #765 steps S0–S4, S7's measurement pass, part of S8, and S9. Assessment:
research/Indexing/olc-btree-assessment-2026-08.md. Docs half: Typhon-Claude PR.Three correctness defects fixed. None of them was the defect the plan predicted. Every step that measured something changed the plan; every step that executed the plan as written was either already done or wrong.
Movepicks its INSERT leaf with a reader's descentboolthe stress fixture had been discarding for monthsNullReferenceExceptionin the pessimistic spill pathS0 — make the detector able to fail
The premise was that
CheckConsistencycouldn't fail. It was worse than that: it had been detecting a real defect on every single run and the result was thrown away. Five consecutive runs emitted 2–3 separator violations each and reported PASSED; one was byte-identical across all five.Movechose the leaf it would insert into withOptimisticDescendToLeaf's defaultfollowRightLink: true. That walk is a reader's tool — it hops right until the key falls inside a leaf's contents — but a new key is in no leaf, so it runs one leaf past the owner, andMoveinserted below that leaf's separator. Reproduces with one thread and one key range. Reads survived it (the same right-walk that causes it also recovers from it), which is exactly why it stood; the insert path passesfalseon purpose and cannot recover.Fixing it also removed work: same-leaf moves stopped being misrouted down the two-leaf path, taking
Stress_MoveSameLeaffrom 12 restarts / 109 pessimistic fallbacks to 0 / 0.TryCheckConsistencyis gone;CheckConsistencythrows at all nine sites. Reverting only theMovefix now reddens seven tests — the four new ones and three existing stress tests that had reported PASSED for months.The nightly's bare
continue-on-error: trueis replaced bybench/aws/nightly-known-red.txt, where every entry carries an issue. A failure not on the list fails the job; an allowlisted test that passes emits a warning, because these fixtures are flaky and one green run proves nothing. Both branches were exercised against synthetic trx before landing.S1 — four invariants the checker could not see, each with a mutant
Intra-node key ordering (a leaf holding
[1, 9, 3, 5, 12]passed every prior assertion — they only ever readGetFirst/GetLast), descent-reachable ∩ chain-reachable leaf sets,EntryCountvs materialised cardinality, and latch residue at quiescence. Walk caps are failures now instead of silent truncations that then render a verdict.Every one ships with a
[RuleMutant]that builds a healthy tree, asserts the validator is silent, breaks exactly one thing, and requires that validator's own message — because a green check and a check that cannot go red are indistinguishable from outside. RulesIXS-04,IXS-05.#739 / #297 — the descent overshoot
The right-walk tests only
key <= leaf.lastKeyand can only travel right, so overshooting is unrecoverable by construction. The branch counters were unambiguous: 6 events, all on the general-descent branch, all withkey < landedLeaf.firstKey, on leaves of 14–21 entries where a merge had just shifted keys left.The naive guard (
key < firstKey) is #740 in a new place — that band is legitimate for a genuinely absent key.KeyBelowLeafLowerBoundalready draws the line correctly, against the previous leaf's HighKey. Same predicate as the four write sites, now on the read path. Recorded asIXS-06.Cost, measured honestly:
Lookup_Miss197.8 → 217.4 ns median, 3 runs a side, non-overlapping. +11%.Lookup_Hituntouched — the guard lives inside thekeyIndex < 0branch a hit never enters. A real price for a correct answer, quoted in the rule so nobody re-derives it.S2 / S3 — one predicate, and instruments that stop lying
KeyOutsideLeafAuthoritystates both bounds once; all 14 leaf-write sites audited (fourMove/MoveValuevia the shared predicate, the OLC insert path via both halves,InsertIterativevia its move-right loop — now literallywhile (KeyAboveLeafUpperBound(...))instead of a fourth longhand copy — and the fast paths structurally).BTree.Move.csheld 31WriteUnlockand zeroAbortWriteLock, of which only ten follow a real mutation. 21 converted. Measured on restarts, which unlike spin counts aren't affected by how expensive a spin is: −10% to −23% in every fixture that exercisesMove; the only two that didn't improve are the two insert-only workloads that never call it.The write-lock spin counter was generating the cross-core traffic it existed to report — the new deadline sampler caught 2,861,200 increments in one second with restarts, fallbacks, splits and entries all frozen. Now tallied locally and published once.⚠️ Spin counts are not comparable across this change: a cheaper iteration fits more of them into the same wait.
S4 — the first concurrency baseline this design has ever had
Four concurrent benchmark classes had never produced a recorded number, because
benchmark.sky.yaml's default profile selects--allCategories Regressionand they carriedBTreeMedium— a profile that must be dispatched by hand and never was. Same shape as the[Explicit]finding. Five representatives promoted; verified via--list flat.Reads scale:
ConcurrentLookup_RandomKeys161.5 → 16.7 ns, 9.65×. Writes peak at 4–8 threads then regress. Both single-hot-leaf workloads go backwards —SecondaryUpdate_HotLeaf3.3× slower at 32 threads,ConcurrentInsert_Monotonic8× slower. Cross-CCD doesn't explain it: lookups keep improving 16→32 threads through the same boundary.ConcurrentInsert_Monotonicis deliberately excluded from the tracked category — it never resets, so the tree grows 50k keys per iteration through warmup and iteration 5 measures a taller tree than iteration 1. Error bars ≈ the measurement.#221 / S8 — build the instrument, then use it
There was no
Movebenchmark anywhere, which is why #221's "40–50%" claim was never checkable. AddedMove_SameLeaf/Move_CrossLeaf.Move_SameLeaf: 310.4 → 267.0 → 248.2 ns (−20%) — the fast path, then reorderingKeyAboveLeafUpperBoundto compare before readingGetNext. Three stages, each separated by more than its spread.Move_CrossLeaf: 340.7 → 392.5 ns (+15%). The fast-path test is pure cost when it misses, and I'm leaving that visible rather than averaging it away. Net win only where same-leaf moves dominate — which is the workload #221 was filed about.Not done, deliberately: propagating the cached leaf flag through
GetChildis unsafe — OLC readers call it on a parent whose version isn't validated yet, so dereferencing the child can crash before restart can signal (#297), and deriving it fromHeightis rejected by an equally explicit comment onRoot. DevirtualisingBaseNodeStorageis real but it's a generic-parameter refactor of the whole type and deserves its own issue.S7 — a crash, and a classifier that invented a hang
The classifier read counters without first asking whether the iteration was still running. A body finishing a millisecond after the deadline freezes everything, which read as "lock cycle" — the old
HANGlabel in better clothes, and it produced the only STUCK sample I had. It reports LATE now.Then the tree: one
NullReferenceExceptioninInsertLeaf. Both spill branches rewrite the separator throughrelatives.Left/RightAncestor, but eligibility was decided only from the leaf chain — and a chain neighbour can live in a different subtree, leaving the ancestordefault. Requiring the ancestor before choosing a spill fixes it; split is the documented always-correct fallback.After both: STUCK is gone. Only
RESTARTINGremains, 2 in 93,883 iterations at a punitive 10 s budget under 32 noise threads.Verification
check-rule-scopes.py,audit-rule-coverage.py(0 blocking),check-doc-links.pyall pass.Two deliberate regressions, both documented
Lookup_Miss+11% (buys a correct answer; devirtualisation would pay most of it back) and cross-leafMove+15% (buys −20% on same-leaf). Numbers are in the rules and commit messages so the trade is reviewable rather than buried.Not started, and why
S5 (delete borrow/merge) existed to make #739 unrepresentable. #739 is fixed for one predicate call, so 5–8 days plus permanent space bloat now needs a fresh argument — and no-merge would make
emptyAndLinkeda permanent legitimate state, which is an unconditional #738 on every delete workload.S6's load-bearing number does not survive re-measurement:
InsertIterative↔RemoveIterativeis 0.50, not 0.83–0.85 over whole method bodies (the original figure was computed over two selected regions, which its own parenthetical names). The axis ordering survives, so §9 is still wrong; the one-skeleton plan does not.