Electric progressive: apply and confirm changes to visible rows during the background full sync
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 30/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
Rechercherichtung
Start with packages/electric-db-collection/src/electric.ts and the progressive witnesses in electric-live-query.test.ts; trace how buffered changes, snapshot metadata, txid evidence, and the atomic swap interact. Use the recovery and descriptor-isolation oracles to check ordering around snapshot xmin, xmax, and xip, then inspect persistence and reset behavior. Done means visible-row changes and their txids are applied before the swap, with no stale rollback or duplicate application, and the stated evidence passes.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
During a progressive collection's background full sync, Electric buffers stream changes and their txids until the atomic swap. #2115 makes a live query over a progressive source ready as soon as its own subset loads. A user can now edit a visible row while the full sync is still running. That mutation's awaitTxId cannot resolve until the swap. If the full sync takes longer than the awaitTxId timeout, the handler throws and the optimistic change rolls back.
The stream starts at once, so Electric receives the confirming change long before the swap. Electric could apply that change and its txid during buffering for rows that the client already shows.
Current behavior
In packages/electric-db-collection/src/electric.ts:
- While
isBufferingInitialSync()is true, change messages go tobufferedMessages. Their txids are not added tonewTxids. The comment says "txids will be extracted during atomic swap". - The atomic swap on the first
up-to-dateapplies the buffered changes, extracts their txids, and then resolves txid waiters throughpublishEvidence.
As a result:
- Confirmation waits for the full sync.
awaitTxId(txid)for a write to a visible row resolves only at the swap. - Visible rows go stale. A ready progressive query shows its subset snapshot rows unchanged until the swap. #2115 records this as a known limit, and
electric-live-query.test.tspins it ("a ready query's rows update only when the full sync completes").
Before #2115, useLiveQuery already rendered rows in this window. Suspense users now reach it too.
Proposal
Apply stream changes during buffering for keys that a subset snapshot already loaded, when the change is newer than that snapshot. Record their txids when the change applies. Keep buffering every other change until the swap.
Electric has the needed pieces:
progressiveSnapshotRowskeeps the snapshot row for a key when a later stream update needs that row as its baseline.- Each
fetchSnapshotreturns snapshot metadata, andisVisibleInSnapshotcan order a txid against it.
The txid must resolve only when its change is visible. If Electric confirms a change that it still buffers, the optimistic state drops and the old snapshot row shows again until the swap.
Questions to settle
- Ordering. A change can be older than, or included in, the snapshot that loaded its key. Use the snapshot's xmin, xmax, and xip list to decide whether to apply the change, skip it as already included, or keep buffering it.
- The swap. The swap must not apply an early-applied change a second time, and it must not move a row back to an older value.
- Keys outside any subset. Changes to keys that no subset loaded stay buffered, so their txids stay unconfirmed until the swap. Decide whether
awaitTxIdshould report this case, or whether a write to a row the client never loaded is outside scope. - Must-refetch. A reset during buffering discards the subset rows. Changes applied early before the reset must follow the reset's truncate rules.
- Persistence. Early-applied changes go through the same commit and receipt path. Check resume metadata and
seenTxidsevidence for persisted collections.
Evidence to add
- Extend the progressive witnesses in
electric-live-query.test.ts. A write to a visible row during buffering must become visible, and itsawaitTxIdmust resolve before the swap. - Flip the pinned freshness test on purpose, and update the limit in
packages/db/src/query/live/ARCHITECTURE.mdand in the #2115 review record. - Add an ordering lane with changes before, inside, and after the loading snapshot, checked against an independent model. The Electric recovery and descriptor-isolation oracles already generate progressive histories and are a good place to start.
- A hostile control: a design that confirms a txid without applying its change must fail at the first checkpoint after confirmation.
Related: #2113, #2115, #2118.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 3.9k
- Forks
- 272
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 235
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/db
-
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 8/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 58/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 5/100
TanStack/db#2139 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
high priority
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
CI-CMG/deep-sea-corals-exb#84 · 1 Kommentar ·
-
Create/import wallet form shows raw "password must be at least 1 characters" instead of the translated messageEvtl. vergeben @CapThunder19 hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
joinmarket-webui/jam#1538 ·
Maintainer antworten meist innerhalb von 1 Tag
-
t0ggles
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
nolimits4web/swiper#8240 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag