Skip to content
Source
Sign inSign up
TanStack/db

fix(db): keep settled optimistic rows while their server row waits behind a persisted write #2208

MergedKyleAMathewsmerged 11 commits intomain fromrefs/pull/2208/headmerged by KyleAMathews

Showing 10 changed files with 42 additions and 1 deletion (loading 7).

x
0 of 10 viewed, 10 left
6 additions and 0 deletions.changeset/deferred-sync-held-rows.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/db': patch
+'@tanstack/db-sqlite-persistence-core': patch
+---
+​
+Keep a settled optimistic row visible while its server row waits behind an earlier persisted write. Previously, two quick writes to one row in a persisted Collection could briefly show the row before the second write.
2 additions and 1 deletiondocs/contributing/glossary.mdModified
View file
@@ -29,7 +29,8 @@
| optimistic transaction | A local mutation transaction whose intent may later complete or roll back. | Sync transaction. |
| optimistic state | The rows an optimistic transaction overlays on the applied synced rows while its mutation function runs. It drops when the mutation function settles, whether it fulfills or rejects. | Retained snapshot or accepted local snapshot. |
| accepted sync transaction | A committed sync transaction that core, or a wrapping sync after its durable step, has taken. It always applies, in commit order. While an optimistic transaction is persisting it is held, and it applies in the publication that drops that transaction's optimistic state. Handler-facing writes and Collection readiness wait for acceptance; commit receipts and subset loads wait for visibility. | Visible or applied sync transaction. |
-| held optimistic row | A successful transaction's optimistic row kept only while a queued sync transaction touches its key, so the drop and that transaction publish together. Its source attribution follows the key-and-timing rules in [VirtualOrigin](../reference/type-aliases/VirtualOrigin.md), not source-client identity. | Retained or accepted snapshot. |
+| deferred sync transaction | A committed sync transaction that a wrapping sync has not handed to the Collection yet, because an earlier durable write is still running. Like a queued sync transaction, it holds settled optimistic rows on its keys until it applies. | Queued or accepted sync transaction. |
+| held optimistic row | A successful transaction's optimistic row kept only while a committed sync transaction that has not applied touches its key, so the drop and that transaction publish together. The transaction may be queued in the Collection or deferred behind a wrapping sync's durable step. Its source attribution follows the key-and-timing rules in [VirtualOrigin](../reference/type-aliases/VirtualOrigin.md), not source-client identity. | Retained or accepted snapshot. |
| Collection status | One public Collection lifecycle value: `idle`, `loading`, `ready`, `error`, or `cleaned-up`. | Subscription status. |
| subscription status | One subscription value: `ready` or `loadingSubset`. | Collection status. |
| subscription | A consumer of Collection changes with its own subset demands and lifecycle. | Collection, query, or transport. |
34 additions and 0 deletionsdocs/contributing/oracle-coverage.mdModified
View file