Electric resume check puts a lagging tab in error when a peer deleted the row it updates

オープン
#2,267 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
sqlite, typescript
領域
database, testing

調査の方向性

Start with the pinned replay in packages/browser-db-sqlite-persistence/tests/multi-tab-electric-oracle.test.ts and run the Vitest command from the issue to confirm the failure. Then trace the resume check and shared durable row handling; the issue points to peer commits mixing with this tab's stream state. Done means the replay passes, the resumed tab avoids error, and tabs show the server rows after catching up.

索引モデルが issue の本文から書いたものです。

説明

Summary

Electric's resume check can put a persisted Collection in error when several tabs share one persisted database. A resumed tab that lags behind a peer receives an update for a row that the peer's commit already deleted from the shared durable rows. Electric treats the update as a row it never sent and fails with Electric resume state referenced an unseen row; a full snapshot is required.

The resume check assumes that the local rows came from this tab's own stream. With shared persistence, the local rows also reflect peers' commits, which can be ahead of this tab's stream.

main has the same behavior (checked at b8d8ee07c).

Reproduction

The generated multi-tab oracle in #2265 found this history and shrank it:

  1. Two eager tabs share one database. Both deliver the initial snapshot (rows 1 and 2).
  2. Tab B reloads. Its new stream resumes from the persisted position.
  3. The server updates row 2, deletes row 1, deletes row 2, and inserts row 1 again.
  4. Tab A's stream delivers all four changes and up-to-date. A commits them, so the durable rows hold only row 1.
  5. Tab B applies A's commit, so it no longer holds row 2.
  6. Tab B's stream delivers the same changes. The first message updates row 2. B fails with the error above.

The history is pinned as an it.fails replay in packages/browser-db-sqlite-persistence/tests/multi-tab-electric-oracle.test.ts:

cd packages/browser-db-sqlite-persistence
npx vitest run tests/multi-tab-electric-oracle.test.ts -t "keeps a resumed lagging tab out of error"

Expected

A tab whose own stream is legal does not enter error. After every stream catches up, every tab shows the server's rows.

Notes

  • The generated campaigns leave this history out until a fix lands. The coverage map records the exclusion.
  • A fix probably needs the resume check to use evidence from this stream only, not rows that peers' commits supplied. #2209 (ordering source writes by server position) is related, because both come from tabs sharing durable rows at different stream positions.

This issue was written by Isaac.

主要言語
TypeScript
スター
4k
フォーク
286
平均マージ
1日 8時間
マージ済み PR(30日)
105

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/db のほかの issue

TanStack/db の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。