Skip to content
Source
Sign inSign up
TanStack/db

fix(db): publish a retired replay's rows instead of keeping stale ones #2121

MergedKyleAMathewsmerged 7 commits intomain fromrefs/pull/2121/headmerged by KyleAMathews

Showing 7 changed files with 51 additions and 7 deletions (loading 4).

x
0 of 7 viewed, 7 left
5 additions and 0 deletions.changeset/fix-retired-replay-stale-rows.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/db': patch
+---
+​
+A subscriber no longer keeps stale rows after a truncate replay that loses its last demand. When the last requested subset is released while the replay is still loading, nothing can complete the replay. If its current attempt has not failed, the subscriber now receives the rows the source wrote, replaced or deleted during it, instead of keeping the values from before the truncate. A replay whose attempt failed still keeps the last complete snapshot, as before, and a later request updates any row it still shows at an older value.
13 additions and 1 deletiondocs/contributing/oracle-coverage.mdModified
View file
@@ -681,7 +681,19 @@
- The [Collection lifecycle publication oracle](https://github.com/TanStack/db/blob/main/packages/db/tests/collection-subscription-lifecycle-publication-oracle.property.test.ts)
owns exact public rows and change batches. The
[replay oracle](https://github.com/TanStack/db/blob/main/packages/db/tests/collection-subscription-replay-oracle.property.test.ts)
- applies that law to competing replay schedules and same-key writes.
+ applies that law to competing replay schedules and same-key writes. Both
+ models publish a replay's rows when its last owner is released and its
+ current attempt has not failed, and keep a failed one private; the
+ publication oracle's named histories cover a value written, rewritten or
+ deleted during the replay, a row no demand names, a failed replay, a
+ later request that updates a row still shown at an older value, and a row
+ retained by a failed replay that the source deletes before a later replay
+ retires. The replay oracle's named witnesses fail each synchronous failure
+ site (a replay load, an old lease's unload, a new request) and then release
+ the last owner; removing that site's sticky failure fails its witness.
+ Limit: the generated grammars reach a failed retirement followed by another
+ retired replay only rarely (the replay grammar releases one demand, on the