Skip to content

Commit 01f7b32

Browse files
KyleAMathewsTestIsaac
authored
fix(db): replace an obsolete ordered repair before a resumed step (#2419)
* test: keep a deferred refill in its chain across a release pass The CI no-leak failure of ordered-loader.request-authority (seed -1691316941) is a driver misclassification, not a production leak. Replay settlement finishes the repair chain and retires the pre-truncate leases. Each release callback runs a graph pass while joined work defers the chain's refill. The loader blocks ordered refinement for the whole release pass, so the staged refill survives and resumes later as a refetch prefix of the same chain. The driver took the blocked pass for one that consumed the refill. It then classified the refill as a new repair start and the chain's own prefix and tie as leaked. The 2026-11-03 coverage-map trace is the same mechanism. Evidence - Law: no leak, held, and chain-step classification of the request ledger. Authority: ARCHITECTURE.md, "Ordered requests, continuation, and recovery" ("ordered refinement stays blocked until the pass unwinds"; a staged continuation resumes once the request returns). The model rule for chain steps is unchanged. The driver no longer consumes continuation provenance in a release callback's pass. - Reach: ordered-loader.replay-continuation declares release-pass-continuation, deferred-refill, and reset-continuation in histories.states, with two constructed histories. The release-pass history uses an on-demand source. Fixed seed 20261029: 96, 78, 59 of 202 histories. Random: 171-185, 130-135, 124-134 of 402. - RED (unchanged production and driver): the fixed seed failed at path 0:1 with "no leak: requests [3,4] are still held after authoritative request 5 succeeded". Both new fixed regressions failed with "no leak: requests [2,3] ... request 4". 5 failed, 62 passed. - GREEN: the four ordered-*-oracle files pass, 918 tests. The CI replay command passes. - Mutants: M0, the original driver rule, fails 5 tests. M1, which releases the chain's own leases at chain completion, fails 26 tests. M1', which releases every held lease when replay settlement finishes a chain, fails 10 tests. Both fail the new state's histories at the new drain checkpoint for the held law. Before that checkpoint was added, they passed those histories. - Limits: M3, which drops a staged continuation during a blocked pass, survives every property in the file; the coverage map records it as an open gap. A stale request released outside a release pass is not blocked, and no witness measures that path. The leak law is not re-checked after the progress probe's chain. No production code changed. Co-authored-by: Isaac <no-reply@databricks.com> * test: hold every repair-chain acquisition and observe the resumed refill Review follow-up to 0721dec, oracle only; no production change. - Held: the law now covers every successful acquisition of the latest repair chain (prefix, ties, refills), not only its start. A later prefix may retire a prefix member, never a tie or cursor page. Authority: ARCHITECTURE.md, ordered repair ("only the new repair acquisitions remain"; a larger prefix "does not retire ... ties"). - Unblocked release: the driver treats only the stale finite self-release as outside a release pass, identified from its own ledger (the request it is settling, finite, issued before the current epoch, same truncate generation, no full-source lease). Its graph pass is ordinary. - Reach: release-pass-refill-resumed is the required state, observed when a later pass resumes the deferred refill as a new-demand step of the same chain. release-pass-continuation (driver-owed) is measured only. Evidence - Law: held over every chain acquisition; chain-step provenance across release passes. Authority as above, and ARCHITECTURE.md, Ordered requests, continuation, and recovery. - Reach: fixed seed 20261029 reaches release-pass-refill-resumed in 60 of 202 histories (driver-owed: 96); random about 105-128 of 402. Scratch calibration against loader internals: 192 of 192 real pending continuations observed, 0 of 97 driver-only. Self-release classifier against an instrumented production branch: 26 of 26, 0 mismatches over 50,298 releases. The broad campaign meets an unblocked release pass with an owed continuation 3 times at the fixed seed and 1-4 times per random campaign. - RED: reviewer mutant droprefill passed every test at 0721dec and now fails 6 tests (held). m3 and restart passed at 0721dec and now fail 2 tests each, only through the constructed history's required reach. - GREEN: the four ordered-*-oracle files pass, 918 tests, on unchanged production. - Mutants: M0 (old driver rule) fails 5; M1' fails 8; unblock 8; retireown 29; spurious 12. - Limits: restart and m3 are not rejected by any law. A per-chain one-read-per-demand law fails on production (optimistic refill re-read, repeated cursor page after a head insert, replacement start without an epoch move). The coverage map records this as awaiting a maintainer decision. The real subscription receiving path and the refill's publication hold are recorded as unwitnessed. Co-authored-by: Isaac <no-reply@databricks.com> * fix: replace an obsolete repair chain before a resumed step A repair chain whose ordering epoch moved must be replaced before it issues another tie or refill (ARCHITECTURE.md, ordered repair). The settlement path checked that. A continuation that the chain staged, or a window move that joined work blocked, ran later through loadMore. Its exception for a running chain let the obsolete chain issue one more page or refill without a cursor. When that step settled, the real replacement started. loadMore now starts the replacement when a resumed repair step's chain needs replacement. A staged boundary step reaches the same check, because invalidation cleared the boundary it would read. Evidence - Law: no stale step, extended to resumed requests (a request that a pending continuation issues after its chain's epoch moved must start the replacement, so its settlement must not start one again). Also one start per epoch (a chain step does not re-read its start demand unless an optimistic departure, head insert, or source delete happened since). Authority: ARCHITECTURE.md, ordered repair ("before the obsolete chain can issue another tie or refill"). ARCHITECTURE.md now names staged and blocked continuations in that sentence. - Reach: continuation-before-epoch-move (the epoch moves while a repair continuation is owed) in 75 of 10,000 generated histories at fixed seed 20261016 and 56-69 of 10,000 at random seeds; minimum 20. - RED (unchanged production): 6 tests fail, including two existing fixed regressions. Example: "request 3 resumed a repair continuation after its chain's epoch moved, and its settlement started the replacement (request 4)". A scratch production probe counted 38 obsolete steps in one run. - GREEN: the four ordered-*-oracle files pass, 919 tests. The probe counted zero obsolete steps and the laws raised no flags over ten random seeds. - Mutants: restoring the defect fails 7 tests. Dropping the fix only for blocked window moves fails seeds 6 and 7. restart fails 6 tests (one start per epoch). droprefill fails 6. A smaller later prefix retiring a larger prefix passed at 4d12a16 and now fails 3 tests (held law tightened to prefixes at least as long). m3 is still rejected only by reach and stays open. - Size: the minified ordered-source-loader.js grows by 55 B raw, 15 B gzip, 11 B brotli (vite build --minify, built directly; size:compare not run). - Limits: a hung or failed obsolete step is not judged. The law's premise over-approximates; one unreproduced flag appeared under a mutant run. The stale self-release's unblocked pass is a stated assumption without ARCHITECTURE.md authority. Re-reads after new source input are exempted and await a maintainer decision. Co-authored-by: Isaac <no-reply@databricks.com> * chore: add changeset for the ordered repair replacement fix Co-authored-by: Isaac <no-reply@databricks.com> * test(db): stop two ordered-loader laws from flagging correct production The no-stale-step law counted a genuine replacement start's full-source fallback as an obsolete step, and the fake's drain settled a replay while a request of its own attempt was still in flight, which the held law then flagged. Both failed 2 of 40 default random seeds with no mutant. The law now counts a full-source read only when every installed rank is finite, and the drain settles a replay attempt's requests before the replay, as ARCHITECTURE.md's replay participants rule requires. 40 random seeds pass; the review's production mutants are still rejected. Co-authored-by: Isaac <no-reply@databricks.com> * test(db): drop an unnecessary assertion in the obsolete-step law Co-authored-by: Isaac <no-reply@databricks.com> --------- Co-authored-by: Test <test@test.com> Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 8cd8627 commit 01f7b32

5 files changed

Lines changed: 705 additions & 82 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/db': patch
3+
---
4+
5+
Start the replacement of an ordered repair before an obsolete step runs. When the source ordering changed while a repair's next page or refill was waiting, for example behind joined work, the obsolete repair issued one more request before it was replaced.

0 commit comments

Comments
 (0)