Skip to content
Source
Sign inSign up
TanStack/db

Multi-tab Electric: a deleted row returns after a peer reset and deploys #2281

OpenKyleAMathews opened this issue 3 comments
KyleAMathewscommented

Summary

The multi-tab Electric oracle found a history where a deleted row returns. After every tab catches up, durable storage and both tabs still contain row 1. The model expects only row 2.

The failure reproduces on origin/main at 4c39add29 and on the head of #2262 (f276b4ad4). The oracle and the behavior it checks came in with #2265. #2262 does not cause it.

Law

A row that the server deletes stays deleted in durable storage and in every tab after all tabs catch up. A peer reset and a later deploy do not bring back a deleted row.

Counterexample

Oracle: packages/browser-db-sqlite-persistence/tests/multi-tab-electric-oracle.test.ts, test keeps reserved commits lawful across generated multi-tab histories (random or replayed), property browser.multi-tab-reserved-history.

{ seed: -1115798760, path: "1:4:3:3:3:3:3:3:3:3:3", endOnFailure: true }
Counterexample: [{"tabCount":2,"steps":[
  {"kind":"server change","key":1,"pick":0},
  {"kind":"advance","tab":1,"pick":0},
  {"kind":"server change","key":1,"pick":0},
  {"kind":"advance","tab":0,"pick":0},
  {"kind":"peer reset"},
  {"kind":"server change","key":1,"pick":0},
  {"kind":"deploy"},
  {"kind":"deploy"},
  {"kind":"server change","key":1,"pick":0},
  {"kind":"server change","key":1,"pick":0}]}]
Shrunk 10 time(s)

Observation after every tab caught up:

actual   {"durableRows":[{"id":1,"label":"one"},{"id":2,"label":"two"}],
          "tabs":[{"tab":"A","status":"ready","rows":[{"id":1,...},{"id":2,...}],"sourceError":true},
                  {"tab":"B","status":"ready","rows":[{"id":1,...},{"id":2,...}],"sourceError":true}]}
expected {"durableRows":[{"id":2,"label":"two"}],
          "tabs":[{"tab":"A","status":"ready","rows":[{"id":2,...}],"sourceError":true},
                  {"tab":"B","status":"ready","rows":[{"id":2,...}],"sourceError":true}]}

The CI job that found it: Test (sqlite-adapters) on #2262, run 40723478437.

Replay

Run this in packages/browser-db-sqlite-persistence:

TANSTACK_DB_ORACLE_PROPERTY=browser.multi-tab-reserved-history \
TANSTACK_DB_ORACLE_SEED=-1115798760 \
TANSTACK_DB_ORACLE_PATH="1:4:3:3:3:3:3:3:3:3:3" \
npx vitest --run tests/multi-tab-electric-oracle.test.ts -t "generated multi-tab"
  • #2267 is a different symptom: a lagging resumed tab goes into error. This issue is a deleted row that returns.
  • The fixed-seed campaign and the pinned storm histories pass. Only the random campaign reached this history.

Next steps

  • Diagnose which step reintroduces row 1: the peer reset, the deploys, or the reserved-commit replay.
  • Record the trace in docs/contributing/oracle-coverage.md under the multi-tab Electric owner until a fix lands.
  • Fix oracle-first: keep this history as a replay, show RED on the parent, GREEN after the fix, and a hostile mutant that fails.
  1. Two more random-campaign counterexamples reproduce on main (45eeef81a). PR #2231 pins both with it.fails replays that run through each oracle's own driver and checks (commit b02796989).

    1. Multi-tab Electric: a stored row is lost after the tabs stop

    This is the same property as this issue, browser.multi-tab-reserved-history. It is a different history, and the symptom is the opposite: a row that should be stored is missing, where in this issue a deleted row comes back. The history has no peer reset and no deploy.

    TANSTACK_DB_ORACLE_PROPERTY=browser.multi-tab-reserved-history \
    TANSTACK_DB_ORACLE_SEED=-1660880085 \
    TANSTACK_DB_ORACLE_PATH=55:0:1:4:4:4:1:1:1:1:3:4:4:4:4 \
    pnpm --filter @tanstack/browser-db-sqlite-persistence exec vitest --run tests/multi-tab-electric-oracle.test.ts

    Two tabs: server change k1, tab 0 catches up, server change k1, tab 0 catches up, tab 1 catches up, tab 0 catches up, tab 1 stops, tab 0 catches up, tab 0 stops. After every tab catches up:

    actual   durableRows [{id:2}]                  (both tabs show the same)
    expected durableRows [{id:1,label:"v2"},{id:2}]

    2. Persisted sync metadata session: a reload keeps a seed's metadata

    The property is sync-metadata-session.persisted-peers-full, seed 654774679. It failed CI on #2231. This is a different subsystem from the multi-tab case and is recorded here only to keep track of it.

    TANSTACK_DB_ORACLE_PROPERTY=sync-metadata-session.persisted-peers-full \
    TANSTACK_DB_ORACLE_SEED=654774679 \
    pnpm --filter @tanstack/db-sqlite-persistence-core exec vitest --run tests/sync-metadata-session-persisted.test.ts

    The shrunk prefix is begin seed(1,bare) insertOverSeed(1) begin reinsert(1) commit peer(2,reload). It breaks the law that a source reads its own row metadata (metadata.row.get):

    expected {"1":"<absent>","2":{"peer":{"s":6}}}
    actual   {"1":{"cached":true},"2":{"peer":{"s":6}}}

    Neither case shares a proven root cause with this issue. The random campaigns can still draw both histories until they are fixed.

  2. Another CI counterexample with the deleted-row resurrection symptom, found on PR #2286.

    • Job: Test (sqlite-adapters), run 40738113012, attempt 2
    • Commit: 4b0cfec1e648a9ed705c14c2a91e311f8c35df82
    • Oracle: packages/browser-db-sqlite-persistence/tests/multi-tab-electric-oracle.test.ts
    • Test: keeps reserved commits lawful across generated multi-tab histories (random or replayed)
    • Property: browser.multi-tab-reserved-history
    • Failed after 79 tests; shrunk 15 times.
    { seed: -699129038, path: "78:2:0:3:9:12:12:13:12:13:13:13:13:14:14:14", endOnFailure: true }
    Counterexample: [{"tabCount":2,"steps":[{"kind":"server change","key":3,"pick":0},{"kind":"server change","key":3,"pick":0},{"kind":"catch up","tab":0,"pick":0},{"kind":"catch up","tab":1,"pick":1},{"kind":"server change","key":1,"pick":0},{"kind":"server change","key":1,"pick":0},{"kind":"catch up","tab":0,"pick":0},{"kind":"advance","tab":0,"pick":0},{"kind":"recover","tab":1,"pick":0},{"kind":"recover","tab":0,"pick":0},{"kind":"catch up","tab":0,"pick":0},{"kind":"catch up","tab":0,"pick":0}]}]

    At the after every tab caught up checkpoint, durable storage and both ready tabs still contain row 3 (label: "v1"), while the model expects only rows 1 and 2:

    actual   {"durableRows":[{"id":1,"label":"v4"},{"id":2,"label":"two"},{"id":3,"label":"v1"}],"tabs":[{"tab":"A","status":"ready","rows":[{"id":1,"label":"v4"},{"id":2,"label":"two"},{"id":3,"label":"v1"}]},{"tab":"B","status":"ready","rows":[{"id":1,"label":"v4"},{"id":2,"label":"two"},{"id":3,"label":"v1"}]}]}
    expected {"durableRows":[{"id":1,"label":"v4"},{"id":2,"label":"two"}],"tabs":[{"tab":"A","status":"ready","rows":[{"id":1,"label":"v4"},{"id":2,"label":"two"}]},{"tab":"B","status":"ready","rows":[{"id":1,"label":"v4"},{"id":2,"label":"two"}]}]}

    Replay from the repository root:

    TANSTACK_DB_ORACLE_PROPERTY=browser.multi-tab-reserved-history \
    TANSTACK_DB_ORACLE_SEED=-699129038 \
    TANSTACK_DB_ORACLE_PATH='78:2:0:3:9:12:12:13:12:13:13:13:13:14:14:14' \
    pnpm --filter @tanstack/browser-db-sqlite-persistence exec vitest --run tests/multi-tab-electric-oracle.test.ts -t 'random or replayed'

    This shrunk history has catch-up, advance, and recover steps, with no peer reset or deploy. It shares this issue's observed deleted-row resurrection symptom; a shared root cause has not been established. This report preserves the CI evidence; the replay has not been run locally. PR #2286 changes only the Solid peer range and a changeset.

  3. A further counterexample from the same generated multi-tab Electric oracle occurred on the documentation-only PR #2295 at ce39517f66dd74588e79b4f12f68e7ccca70d8f8.

    • Failed Test (sqlite-adapters) job
    • Owner: packages/browser-db-sqlite-persistence/tests/multi-tab-electric-oracle.test.ts
    • Property: browser.multi-tab-reserved-history, random campaign
    • Seed: -1371495859
    • Path: 75:0:0:0:0:0:0:1:1:0:0
    • Checkpoint: after every tab caught up (check, line 1162)
    • One assertion failed after 76 generated tests; the Browser package reported 844 passing tests and no type errors.
    {"tabCount":2,"steps":[{"kind":"recover","tab":0,"pick":0},{"kind":"server change","key":1,"pick":0},{"kind":"advance","tab":0,"pick":0},{"kind":"advance","tab":1,"pick":0},{"kind":"advance","tab":0,"pick":0},{"kind":"peer reset"},{"kind":"advance","tab":0,"pick":0},{"kind":"server change","key":1,"pick":0}]}

    At the final checkpoint, durable storage and both tabs contain row 1 with label one; the model expects row 1 with label v2. Tab A is in error, tab B is ready, and both have a source error. Tab A's preload rejects with AbortError: Sync transaction was aborted before application.

    This trace shares the peer-reset regime and final catch-up mismatch with this issue. It has no deploy step, and its exact relationship to the earlier counterexample has not yet been diagnosed. Preserve both traces and distinguish a production convergence defect from a model or recovery-checkpoint defect before changing either one. The CI assertion is the evidence; this trace has not yet been replayed independently.

    Replay from packages/browser-db-sqlite-persistence on the recorded commit:

    TANSTACK_DB_ORACLE_PROPERTY=browser.multi-tab-reserved-history \
    TANSTACK_DB_ORACLE_SEED=-1371495859 \
    TANSTACK_DB_ORACLE_PATH=75:0:0:0:0:0:0:1:1:0:0 \
    pnpm exec vitest run --coverage.enabled=false --typecheck.enabled=false \
      tests/multi-tab-electric-oracle.test.ts -t 'random or replayed'

    The maintainer explicitly requested recording this trace here and retrying CI while leaving the bug open. No oracle, assertion, or run budget has been weakened. A later green random campaign does not close this issue. This is separate from the replay-retention deferral in #2294.

Sign in to join this conversation.