Skip to content
Source
Sign inSign up
TanStack/db

fix(query-db): keep a reacquired Query's rows across an older release #2206

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

Showing 5 changed files with 227 additions and 1 deletion (loading 2).

x
0 of 5 viewed, 5 left
5 additions and 0 deletions.changeset/stale-reacquired-query-ownership.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/query-db-collection': patch
+---
+​
+Keep a reacquired Query's cached rows when an earlier release of the same Query publishes later. Previously, reacquiring a stale on-demand Query while its release waited behind another sync transaction could drop its rows, and they stayed missing if the refetch failed.
47 additions and 1 deletiondocs/contributing/oracle-coverage.mdModified
View file
@@ -1064,7 +1064,53 @@
published owners over accepted ownership. A release/reacquisition history also
holds publication, reacquires the same cached Query, then proves the older
release cannot erase the new claim by releasing it and observing an empty
-public row set. Larger overlap schedules, window ownership outside the ordered
+public row set. That history uses infinite `staleTime`, so reacquisition starts
+no fetch. A sibling table crosses a stale reacquisition whose refetch fails,
+returns the same rows, or returns no rows; the refetch settles while publication
+is held or after the older release publishes; zero to two peer leases own the
+first row until after the refetch; and the reacquired result has one or two
+rows. Its independent model keeps each active observer lease's latest
+successful result and compares public rows while held, after publication,
+after the refetch, after every peer's release, and after the reacquired
+release. On `main` at `31dad2dd3` 20 of its 42 cells fail: the older release's
+empty ownership entry made the cached result look already applied, so the
+reacquired lease owned nothing. A row only it owned disappeared at
+publication; a row a peer also owned disappeared when the last peer left. The repair marks a released lease's entry and