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

Abierto
#2,267 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
sqlite, typescript
Área
database, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
4k
Forks
286
Merge medio
1 d 8 h
PR fusionados (30 d)
105

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TanStack/db

Todos los issues de TanStack/db

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.