Skip to content
Source
Sign inSign up
TanStack/db

fix: preserve persisted Query writes across overlapping refetches #2002

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

Showing 9 changed files with 103 additions and 13 deletions (loading 6).

x
0 of 9 viewed, 9 left
7 additions and 0 deletions.changeset/persisted-query-overlap.mdAdded
View file
@@ -0,0 +1,7 @@
+---
+'@tanstack/db': patch
+'@tanstack/db-sqlite-persistence-core': patch
+'@tanstack/query-db-collection': patch
+---
+​
+Keep accepted Query results and parallel mutation-handler writes in order when SQLite persistence overlaps a refetch. Refresh the Query cache when a queued write applies, so an earlier row cannot overwrite the latest durable value.
72 additions and 0 deletionsdocs/contributing/oracle-coverage.mdModified
View file
@@ -313,6 +313,78 @@
optimistic-history owners still need a joint generated witness
for competing source writes around mutation settlement.
​
+The Query ownership oracle enumerates five controlled persisted-refetch
+overlaps after initial load: a committed metadata-only transaction before
+Collection publication followed by a newer refetch, direct `writeUpsert`, or
+mutation-handler `writeUpsert`; and a row transaction before durability
+followed by a newer refetch or direct `writeUpsert`. It checks the latest
+public receipt, public and stored rows, and the Query Collection error ledger.
+Adjacent controls cover precommit cancellation and cleanup fencing. With the
+Query result controller's post-commit supersession guard, refetch and direct
+write successors pass before publication and durability. Both before-publication
+mutation-handler schedules now settle: an immediate write queued before the
+older normal source reaches core and one queued after it begins waiting both