browser-db-sqlite-persistence: closing the leader tab fail-stops follower collections with IndeterminateCommitError
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- playwright, sqlite, typescript
調査の方向性
Start by tracing BrowserCollectionCoordinator.assertMutationRouteUnchanged and sendRPC, then follow the persistence runtime paths named in the stack trace: persistAndBroadcastExternalSyncTransactionUnsafe and applyBufferedSyncTransactionUnsafe. Reproduce with two same-origin tabs sharing an OPFS database and close the leader while sync changes arrive. Done means a normal leader close no longer leaves follower collections permanently errored, or the supported reconciliation path is clearly documented.
索引モデルが issue の本文から書いたものです。
説明
Summary
With BrowserCollectionCoordinator, closing the leader tab often puts collections in the remaining tab into a permanent error state. The follower's in-flight rpc:applyCommittedTx for a sync-sourced transaction (an Electric change) waits for the closed leader, times out after 10 s, crosses leadership, and rejects with IndeterminateCommitError. The collection fail-stops, and the tab stops getting live rows.
Versions
@tanstack/db0.12.3@tanstack/db-sqlite-persistence-core0.4.7@tanstack/browser-db-sqlite-persistence0.2.32 (OPFS,openBrowserWASQLiteOPFSDatabase)@tanstack/electric-db-collection0.5.8- Chromium (Playwright headless shell), two tabs in one browser context, same origin
Setup
- One OPFS database, shared by the tabs through
BrowserCollectionCoordinator({ dbName })andcreateBrowserWASQLitePersistence({ database, coordinator }). - Seven persisted Electric collections (eager and on-demand), created with
persistedCollectionOptions({ ...electricCollectionOptions(...), persistence, schemaVersion: 1 }).
Steps
- Open tab A. It becomes the leader for every collection.
- Open tab B. Wait until both tabs show live rows.
- Close tab A (
page.close(), a normal close, not a crash). - Keep inserting rows on the server, so that tab B's Electric streams deliver changes.
Observed
3 of 6 runs. About 10 s after tab A closes, tab B logs this (ids shortened):
IndeterminateCommitError: Commit outcome is indeterminate for collection "messages":
rpc:applyCommittedTx:req crossed leadership from 65c2… (term 1) to 2f07… (term 2)
<- Error: RPC rpc:applyCommittedTx:req timed out after 10000ms
at BrowserCollectionCoordinator.assertMutationRouteUnchanged
at BrowserCollectionCoordinator.sendRPC
at async PersistedCollectionRuntime.persistAndBroadcastExternalSyncTransactionUnsafe
at async PersistedCollectionRuntime.applyBufferedSyncTransactionUnsafe
The same error occurred for other collections in other runs, sometimes through flushQueuedHydrationTransactionsUnsafe. The collection stays in error, and every later update() on it throws. While tab A closes, it logs PersistedCollectionDurabilityError ... The page is closing its SQLite connection. In the other 3 runs, tab B took over every leader lock, and sending and receiving continued.
Expected
A normal leader-tab close should not fail-stop the other tab's collections. #1845 makes a leader change during a mutating RPC indeterminate and leaves reconciliation to the application. For a transaction that comes from the sync source, the source can deliver the same changes again from the durable resume offset. So one of these seems possible:
- The closing leader rejects or drains pending RPCs (for example on
pagehide), so the follower does not wait 10 s for a leader that has gone. - For sync-sourced transactions, the runtime reconciles by itself: it re-hydrates and resumes from the persisted offset instead of fail-stopping.
- If the application must reconcile, document how to do it for a sync-sourced collection. Is
collection.cleanup()followed by a new collection the intended path?
Not done
- No standalone reproduction yet. We saw this in an app, driven by Playwright. We can try to reduce it if that helps.
- 主要言語
- TypeScript
- スター
- 3.9k
- フォーク
- 268
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 206
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/db のほかの issue
-
Reusable queries: standalone descriptor resolution and nested alias composition limits対応中かも @KyleAMathews が 2 日前に担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
electric-db-collection: on-demand + persistence fails after relaunch with "Snapshot requests are not supported in full mode"対応中かも @KyleAMathews が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
TanStack/db#2056 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
[Docs] README: FAQ setup command, IDA in the intro, Node badge対応中かも @akram1089 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
[Feature]: [P3] engine-rs: the package source hash should ignore line endings and untracked filesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
maniator/verticopolis#880 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
siyuan-note/siyuan#20353 ·
メンテナーはふだん 1 日以内に返信
-
afk-ok area:data-quality importer size:S
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
enorm-labs/event-junkie#3027 ·
メンテナーはふだん 1 日以内に返信