Repository navigation
fix(sync): apply finds natural-key rows whose uid was never filled (T13273) - #1922
Merged
Merged
Conversation
…13273) A natural-key row (dependencies, relations) has uid NULL until the open- time identity fill; the sealer journals it under the natural uid. Lookups by uid missed it: the own echo of every such insert voided on its origin with a UNIQUE guard conflict (never sequenced), and a rebase could not rewind it, so replicas diverged. The apply now adopts the row first: the row with no uid whose local key matches the op's `k` (refs resolved) gets its uid (the fill's derived value; capture never fires on the identity column). Done before planning each staged txn and before rewinding each local one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task: T13273
Stacked on #1921 (R-4a), which carries the closure widening this PR's convergence test needs.
The bug (pre-existing, from the T12344 applier)
A natural-key row (
tasks_task_dependencies,tasks_task_relations, …) keepsuidNULL until the open-time identity fill. The sealer journals it under the natural uid, which it derives from the key (the op carriesk). The write API looks rows up byuidonly, so:guardconflict was recorded. The echo was never sequenced and kept its undo. Reproduced on real replicas: A inserts the edge TA→TB, syncs its own echo, and the result isvoid: 1, conflicts: 1.The fix
adoptNaturalRow(table, uid, localKey). It finds the row with no uid whose local key matches and writes the uid. That is the same derived value the identity fill writes, and capture never fires on the identity column.adoptNaturalRowswith the op'sk, with refs resolved to local keys, at two points: before planning each staged txn, and before rewinding each local txn.Tests
applied, the uid fill is not journaled, and the replicas match.Locally green:
--base origin/feat/T13193-footprints) and 40.🤖 Generated with Claude Code