Skip to content
Source
Sign inSign up
TanStack/db

fix(persistence): reconcile source commits after leader close #2088

MergedKyleAMathews(GitHub profile, opens in a new tab)merged 14 commits intomain fromrefs/pull/2088/headmerged by KyleAMathews(GitHub profile, opens in a new tab)

Showing 43 changed files with 154 additions and 0 deletions (loading 40).

x
0 of 43 viewed, 43 left
10 additions and 0 deletions.changeset/reconcile-source-commit-after-leader-close.mdAdded
View file
@@ -0,0 +1,10 @@
+---
+'@tanstack/db': patch
+'@tanstack/db-sqlite-persistence-core': patch
+'@tanstack/browser-db-sqlite-persistence': patch
+'@tanstack/electron-db-sqlite-persistence': patch
+---
+​
+Keep source-backed persisted Collections usable when a writer tab closes after a commit but before its reply. Certify the original transaction with the new writer and reload peers without duplicating unchanged row events.
+​
+Forward exact-ID reconciliation through the Electron persistence bridge and require matching protocol v4 peers.
11 additions and 0 deletionsdocs/contributing/glossary.mdModified
View file
@@ -56,6 +56,16 @@
`source session`. Use `sync run` for the local Collection sync invocation
and a provider-qualified `provider session` for a remote lifecycle.
​
+## Persistence coordination terms
+​
+| Term | Meaning |
+| --- | --- |
+| durable election term | A per-Collection leadership term reserved in SQLite before a Browser or Electron coordinator announces ownership. Each election gets a greater term even when the previous owner committed no row. |
+| publicly applied row version | The durable row version whose rows the persisted wrapper has applied to the public Collection. A position-only resume snapshot can observe a later version without applying its rows. A schema reset rebinds this version to the new reset epoch. |
+| durable anchor | The row version and reset epoch observed before one source sync transaction is sent to a coordinator. If both still match and the exact transaction ID is absent, the replacement leader may apply that transaction once. |
+| exact-ID reconciliation | The replacement leader checks one immutable source transaction ID under the SQLite writer lock after its RPC result becomes indeterminate. A present ID acknowledges the original commit; an absent ID needs an unchanged durable anchor. |