Skip to content

cherry-pick: Stop retried replicated writes from re-applying a duplicate that already committed (conflicts → v5.3) - #3524

Merged
kriszyp merged 1 commit into
v5.3from
kris/3453-retry-provenance-v5.3
Oct 24, 2026
Merged

kriszyp merged 1 commit into
v5.3from
kris/3453-retry-provenance-v5.3

Conversation

@kriszyp

@kriszyp kriszyp commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

⊙ Problem

This brings #3453 to v5.3. On RocksDB, a replicated write that retries after a commit conflict skips every audit duplicate check. If another delivery already committed, the retry applies it again and a CRDT add counts twice: under a newer write, beside an out-of-order sibling ref, or on the replay after an open read snapshot.

🤔 Merge to v5.3 before main?

Yes, as you asked. The port is #3453 as of 723f4ff, before main's #3510, which v5.3 does not have. #3453 itself now carries a merge of #3510.

💡 Solution

Ported with v5.3's single log key: main's receivedLogKey and appendedLogKey both become txnLogKey.

  • On a retry, the walk skips a duplicate only when it reached the entry through links from committed records with known origins (check; ⚠️ look hardest here).
  • A base restamped by an earlier publish or relocate in the same retry round does not count as committed.
  • Keyed lookups stay off on a retry (keyed probe).
  • The open-snapshot replay stops claiming an audit entry its abandoned handle never wrote.

🤔 Keep the numeric origin compare on v5.3?

Yes. #3453 dropped it when it merged #3510, where a per-handle minted key makes it redundant. v5.3 has no minted keys, so it still keeps two unmapped origins at one version apart (compare, test).

⚖️ Alternatives

  • Fix it natively (#3253: check conflicts before the log flush, so no orphan exists) — the better alternative planning review named; it is a rocksdb-js change, and this port stays correct after it lands.
  • Skip on an exact match reached through a link with no recorded origin — rejected by owner ruling: the link can lead to an orphan, which drops a write.

🔧 Changes

✅ Verification

  • replicatedRetryDuplicate.test.js is byte-identical to Stop retried replicated writes from re-applying a duplicate that already committed #3453 at 723f4ff (same-key batch, terminal-abort orphan). With v5.3's original Table.ts and DatabaseTransaction.ts, 6 of its cases fail; with this branch, all pass.
  • replicatedRetryDuplicate + relayedHeadTieDuplicate: 45 passing. test:unit:resources: 4170 passing, 0 failing.
  • The Review-Attention decision list also carries slugs from a first review round that ran against main by mistake; that round reviewed none of this diff.
  • Review raised that N same-key writes in one retry check their siblings N² times. identityBase already loops the same chain; on a retry this calls it once more per write, the same order. N is the writes to one key in one transaction, normally 1–3.

Framing-Verdict: better-alternative-exists (b55f8f526ef5)

Refs #3361

🤖 Generated by Claude Code (Claude Opus 5.5); posted via @kriszyp.

Release target: v5.3 — cherry-pick of #3453 before #3510

Related PRs: #3453 overlaps (source), #3478 overlaps (merged; the v5.3 base this extends), #3510 overlaps (main-only; why this ports 723f4ff), #3476 overlaps (merged on main; ported in #3478), #3499 overlaps (merged on main; ported in #3478), 9 others independent
Complexity: complicated

Review-Coverage: authored=codex; ran=cursor-composer,gemini; declined=claude,cursor-grok,muse,domain; rounds=2; full=1 @ 94d6143

Review-Attention: deep ~470m (critical: DatabaseTransaction.ts, Table.ts; decisions: do-less-alternative, ambiguous-chain-policy, native-root-cause, ambiguous-retry-provenance, logged-commit-liveness, portable-bundle, restore-lock-fallback, named-process-lifetime, archive-capabilities; raised: degraded review, earlier round at this SHA) @ 94d6143

…ate that already committed (→ v5.3)

Backport of #3453 as of 723f4ff, before main's unique local log keys (#3510).
v5.3 has a single txnLogKey, so the received and appended log keys both map to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kriszyp kriszyp added this to the v5.3 milestone Oct 24, 2026
@kriszyp
kriszyp marked this pull request as ready for review October 24, 2026 05:08
@kriszyp
kriszyp merged commit 20f075c into v5.3 Oct 24, 2026
25 of 26 checks passed
@kriszyp
kriszyp deleted the kris/3453-retry-provenance-v5.3 branch October 24, 2026 05:08

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refines the handling of replicated duplicates and retry behavior within transactions, specifically addressing how committed identity is determined before audit I/O. It introduces tracking of the specific transaction handle (committedOn) and retry round (committedRound) for each write operation. This ensures that sibling writes to the same key are only considered as the commit base if they were saved in the current retry round. Additionally, it improves audit walk validation on retries by requiring known committed-origin provenance (walkOriginKnown) to prevent treating orphaned, uncommitted audit entries as proof of a committed duplicate. Extensive unit tests have been added to verify these behaviors under various conflict and retry scenarios. I have no feedback to provide as there are no review comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant