Repository navigation
Description
Is there an existing issue for the same bug?
- I searched open and closed DATA BRANCH issues; none covers primary-key update provenance with foreign-key
ON UPDATEactions.
Branch Name
main
Commit ID
ad143902644719e65fa703df6397a011dc7d7dfa (PR #27996 head reviewed on 2026-09-02)
Other Environment Information
- Local embedded single-CN / single-TN / single-Log test cluster
- Parent table with an integer primary key and a referencing child foreign key using
ON UPDATE CASCADE
Actual Behavior
A branch-side primary-key change is emitted as an independent delete of the old key plus an insert of the new key. DATA BRANCH MERGE and DATA BRANCH PICK replay that as DELETE/INSERT, so the parent-row delete fails with the foreign-key constraint error. An ordinary UPDATE on the same parent key succeeds and cascades to the child.
Expected Behavior
When a source update changes a referenced primary key, Data Branch apply should preserve it as one native destination UPDATE, allowing declared ON UPDATE CASCADE actions to run.
Steps to Reproduce
create database branch_pk_cascade;
use branch_pk_cascade;
create table parent_t (id int primary key, payload varchar(32));
create table child_t (id int primary key, parent_id int,
constraint fk_child_parent foreign key (parent_id) references parent_t(id) on update cascade);
insert into parent_t values (2, 'two');
insert into child_t values (1, 2);
data branch create table merge_src from parent_t;
update merge_src set id = 3 where id = 2;
data branch merge merge_src into parent_t when conflict accept;
-- Control: update parent_t set id = 3 where id = 2; cascades child_t.parent_id.The equivalent PICK setup (source and destination branches, keys(2)) fails for the same reason.
Root Cause and Scope
multi_update deletes the old row while writing the replacement without a durable operation identity. databranchutils.CollectChanges therefore exposes the old row ID/key as a tombstone and the replacement row ID/key as data. buildHashmapForTable and findDeleteAndUpdateBat correlate the two only by primary-key value; once the key changes, there is no safe association.
Matching rows by commit timestamp or iteration order would conflate independent delete/insert operations with updates and could trigger unintended cascades, so it is not a safe fix. This needs an explicit old-to-new update provenance link through the change stream, followed by native UPDATE apply and MERGE/PICK regressions for cascade, non-cascade rejection, and atomicity.
Related
- Related to [Bug]: Data Branch MERGE/PICK rejects non-key updates on referenced rows #27992: fix(frontend): apply Data Branch updates in place #27996 fixes the documented stable-key non-key-update case.
- Related to PR fix(frontend): apply Data Branch updates in place #27996: this issue tracks the distinct primary-key-move protocol gap identified during review.
Activity
gouhongshen commentedon Sep 2, 2026
I investigated this on the issue's stated baseline, PR #27996 head
ad143902644719e65fa703df6397a011dc7d7dfa, using a fresh embedded single-CN/single-TN/single-Log instance built from that exact commit. I am deferring this issue rather than opening a PR because the required fix is a persistent change-stream protocol decision, and no safe local implementation exists on the current contract.Reproduction and executable-test attempt
I constructed a self-contained 82-line BVT draft covering four distinct semantic cells:
UPDATE 2 -> 3into a parent referenced byON UPDATE CASCADE.keys(2)for the same primary-key update, with the PICK destination referenced byON UPDATE CASCADE.DELETE id=2andINSERT id=3are independent statements in one source transaction. This must not acquire UPDATE semantics.Observed results on
ad14390264:ERROR 20101 ... Cannot delete or update a parent row: a foreign key constraint fails.id=2and the child remainedparent_id=2, proving statement atomicity on the current failing path.UPDATE parent_t SET id=3 WHERE id=2succeeded and changed the child toparent_id=3, proving that native UPDATE supplies the required FK action.DATA BRANCH DIFFexposes the primary-key update exactly asDELETE id=2plusINSERT id=3.I did not add this draft under
test/distributed/cases: there is no correct post-fix result to assert until the protocol below is selected and implemented. Adding a skipped/issue-tagged test would not satisfy the executable-proof requirement.Proven root cause and ownership boundary
multi_update.updateOneBatchcalls the relation delete path and then the insert path; no operation identity is passed between them.disttae.Transaction.writeBatchWithAutoIncrEpochKnowngenerates a fresh physical RowID for each insert, so the replacement cannot be associated by RowID with the deleted row.engine.ChangesHandle.Nextcan return only a data batch and a tombstone batch. It has no update/provenance channel.api.Entry_Updateexists as an enum value, repository search finds no TN/logtail/checkpoint/replay implementation that consumes it as a durable row update.2and new-key data3. The existing hash reconciliation is keyed by PK and cannot pair them after the PK changes.This also explains why a frontend-only patch is unsafe. Pairing by commit TS, transaction, or stream order would misclassify semantic cell 4 and could run
ON UPDATE CASCADEfor an independent delete/insert. Reusing the old RowID is not viable because RowID is the physical address assigned to the new append. Carrying only an in-memory marker would fail after checkpoint/recovery, which is inside the supported Data Branch range lifecycle.Required decision before implementation
A complete fix must choose and specify one durable representation, for example either:
CollectChanges; orThat decision must also define mixed-version behavior and the contract for the other
CollectChangesconsumers (table_changes, CDC, ISCP, and publication), plus checkpoint/compaction/restart preservation and bounded GC. These are storage/protocol compatibility choices, not implementation details I can safely infer in a bug-fix PR.There is also a delivery dependency: the issue's stated baseline is the still-open #27996. Current
maindoes not contain its native stable-key UPDATE apply path. Copying #27996's four commits into a #28026 PR would duplicate and expand this issue's scope to #27992 rather than produce a focused change.Decision
Excluded from a PR and deferred pending an approved persistent update-provenance design and the disposition of #27996. No source files were changed and no PR was opened.
fix(frontend): apply Data Branch updates in place (#27996)
gouhongshen commentedon Sep 4, 2026
Automated AI triage
This issue requires human involvement and cannot currently be completed independently by the
automated fix loop.
Reason
Storage, transaction, and Data Branch owners must approve a versioned durable update-provenance contract. The current repository design gate requires an approved design before implementation when persistent/distributed contracts change; no applicable approved design was found.
Evidence
Current MULTI_UPDATE emits separate delete/insert writes; ChangesHandle exports data and tombstones, and Data Branch associates replacements by primary key. A key move loses the association. Independent DELETE/INSERT is an explicit counterexample to frontend heuristics, so a focused frontend patch cannot prove correctness.
Please use this analysis to provide the missing decision, environment, evidence, or ownership
needed before the issue is returned to the AI candidate pool.
gouhongshen commentedon Sep 4, 2026
Triage decision: defer.
Current-main verification (99ed717, fresh embedded single-CN/single-TN/single-Log instance):
Root cause on current main:
A frontend pairing patch would silently convert the independent DELETE/INSERT counterexample into UPDATE semantics and could trigger unintended ON UPDATE actions. An in-memory marker would also be lost across logtail/checkpoint/recovery. The narrowest correct fix therefore requires an approved persistent update-provenance contract spanning CN workspace writes, TN/WAL, logtail, checkpoints/replay, and ChangesHandle, including mixed-version behavior, retention/GC, and semantics for table_changes, CDC, ISCP, publication, MERGE, and PICK.
The prior dependency on #27996 is now resolved because that PR is merged; the protocol/design blocker remains. I attempted the complete public-path regression matrix above, but no passing UT/BVT can be committed until that contract is selected and implemented. A skipped case would not be executable proof.
To promote later: storage/Data Branch owners approve the durable old/new identity representation and compatibility/retention contract. At that point the implementation must include MERGE and PICK cascade success, RESTRICT rejection, independent DELETE/INSERT non-conflation, restart/checkpoint preservation, and failure atomicity tests.
376 remaining items
gouhongshen commentedon Sep 8, 2026
Revalidated this assignment at
f72ca9efbeb3a7c673701e4a135cc6670c33cfde: freshorigin/main, HEAD and merge-base are identical, and the worktree is clean. The group contains only this issue. #27996 is merged; its stable-key fix does not supply primary-key-move provenance.The full root-cause analysis, attempted executable proof, and stopping criteria in #28026 (comment) remain applicable. I inspected the retained
diagnostic_test.goanddiagnostic.logfor this exact head: the native, MERGE, PICKkeys(2), RESTRICT, and independent same-transaction DELETE/INSERT subtests all completed (package 17.313s). This is reused diagnostic evidence, not a new run or proof of a fix. Native UPDATE cascades; MERGE/PICK reject the real key move; rejected operations preserve parent/child rows. The independent DELETE/INSERT counterexample correctly rejects. Existing stable-key MERGE/PICK BVT cases cannot prove this issue fixed.Source reinspection confirms that
multi_update.updateOneBatchdeletes then inserts,ChangesHandle.Nextexposes data/tombstone batches without an update association, and branch reconciliation probes by the old PK. Thus pairing the two records heuristically would change independent DELETE/INSERT semantics. A successful regression requires durable old-to-new identity across storage/replay and branch collection, including PICK selection; an output-helper unit test with a supplied update marker cannot establish it.No approved versioned provenance design was found in the branch design documents or issue-related PR search. The mo-dev design gate requires an approved design for the persistent/wire and cross-owner contract expansion. Storage/Data Branch owners must decide representation, historical/mixed-version behavior, checkpoint/restart preservation, retention bounds, and update-chain/PICK semantics before implementation. Acceptance must cover MERGE/PICK cascade success, RESTRICT and failure atomicity, independent-operation non-conflation, selection boundaries, and persistence.
Per the authorized comment-and-defer path, exclude the sole issue from implementation delivery and replace
severity/s0withdeferred. No workaround, source/test change, commit, push, or Draft PR is made. The missing protocol decision, rather than local build capability, is the blocker.gouhongshen commentedon Sep 8, 2026
Revalidated this sole-issue assignment. Worktree HEAD is
f72ca9efbeb3a7c673701e4a135cc6670c33cfdeand clean; freshly fetched main is now52f5204603946880a9c2cab19a9371bdceca2ac1. The intervening changes concern object search and PK conflict-check cancellation; they do not introduce update provenance. I do not claim a runtime test on the newer main.I inspected the retained exact-worktree-head
diagnostic_test.goand terminaldiagnostic.log(embedded cluster,TestIssue28026Diagnostic, five selected subtests; package completed in 17.313s). This reuses existing diagnostic evidence, not a new execution or fixed-success proof. Native UPDATE cascades 2 -> 3. Exact MERGE and sibling-branch PICK keys(2) reject with ERROR 20101 and preserve parent/child rows. RESTRICT rejects atomically. Independent DELETE/INSERT in one transaction also rejects correctly. The test explicitly checks destination and child contents after each action. The full investigation and attempted executable proof remain at #28026 (comment) . Existing MERGE/PICK foreign-key BVTs change payload with stable keys and cannot prove this issue fixed.Source reinspection confirms separate delete/insert calls in multi_update.updateOneBatch, data/tombstone-only ChangesHandle.Next, and old-PK lookup in findDeleteAndUpdateBat. A real key move must retain an explicit durable old-to-new association; transaction/timestamp/order matching cannot distinguish the independent-operation counterexample. PICK additionally needs to follow that association from the selected old key. A local output test supplying an update marker would bypass the missing producer contract.
No approved provenance design was found in repository design documents or issue-related PR search (which returns merged #27996, explicitly excluding this issue). The required change expands persistent/wire contracts across SQL/CN, storage/recovery and change-stream consumers, triggering mo-dev G-FEATURE-DESIGN. Storage/Data Branch owners must approve representation, atomic publication, update chains/key reuse and PICK semantics, historical/mixed-version behavior, checkpoint/compaction/restart preservation, retention bounds and consumer compatibility. This is the precise stopping reason; there is no safe local patch or successful regression to deliver before that decision.
Per the requested comment-and-defer path, exclude #28026 from a PR and replace severity/s0 with deferred. Required eventual proof includes MERGE/PICK cascade success, native control, RESTRICT, failure atomicity, independent-operation non-conflation, key-selection boundaries and persistence/restart. No source changes, commit, push or Draft PR are made.
gouhongshen commentedon Sep 8, 2026
Revalidated #28026 at freshly fetched
HEAD = origin/main = merge-base = ffabe501da007d526544192e1c280cf0ce2c7022; the worktree is clean. This group contains one coherent issue: MERGE and PICK lose the same primary-key-update provenance.I read CONTRIBUTING.md, the PR template, the nearby producer/collector/reconciliation code, existing MERGE/PICK foreign-key BVTs, and the retained diagnostic source and terminal log from
f72ca9efbeb3a7c673701e4a135cc6670c33cfde. That diagnostic selected all five subtests and completed in 17.313s: native UPDATE cascaded 2 -> 3; MERGE and sibling-branch PICK keys(2) failed with the FK error while preserving destination parent/child contents; RESTRICT MERGE rejected atomically; independent DELETE 2 and INSERT 3 in one transaction also correctly rejected. All four branch DIFF outputs were DELETE 2 plus INSERT 3. This is inspected historical diagnostic evidence, not a new runtime run at ffabe50 or proof of a fix. Full test construction, command, findings and evidence are recorded in #28026 (comment) .Current-source proof remains:
These inspected producer/collector/reconciliation files have no changes since the retained diagnostic revision. Existing FK BVT cases update payloads with stable keys; they cannot establish this issue's key-move behavior.
A successful public-path regression cannot be constructed by supplying an update marker only in an output-helper test: that bypasses the missing producer/persistence contract. Pairing by timestamp, transaction, values or order conflates the independent DELETE/INSERT counterexample with UPDATE and could run unintended cascades. An in-memory association does not survive recovery. No such workaround was added.
The required fix expands persistent/wire contracts across SQL/CN writes, storage/recovery and change-stream consumers. Repository design searches and the issue-related PR search found no approved versioned provenance design (the PR search returned merged #27996). The mo-dev design-first gate therefore blocks implementation delivery. Storage/Data Branch owners must approve durable identity representation and atomic publication, update chains/key reuse, PICK selection, historical/mixed-version behavior, checkpoint/compaction/restart preservation, retention/GC bounds, consumer compatibility and hot-path cost. This missing architectural decision is the precise stopping reason.
Acceptance after design approval must include the exact MERGE and PICK CASCADE cases, native control, RESTRICT rejection, failure atomicity, independent-operation non-conflation, key-selection boundaries and persistence/restart. No fixed-success UT/BVT is claimed. Per the authorized all-members-deferred path, exclude this sole issue from PR delivery and replace severity/s0 with deferred. No source/test changes, commit, push or Draft PR are made.
gouhongshen commentedon Sep 8, 2026
Revalidated this assignment at freshly fetched
HEAD = origin/main = ffabe501da007d526544192e1c280cf0ce2c7022, with a clean worktree. MERGE and PICK are one coherent provenance problem. No new approved design or implementation was found; issue-related PR search returns merged #27996.I inspected the retained
TestIssue28026Diagnosticsource and terminal log fromf72ca9efbeb3a7c673701e4a135cc6670c33cfde: all five diagnostic subtests completed, package duration 17.313s. Native UPDATE cascaded 2 -> 3; exact MERGE and sibling PICK keys(2) rejected with the foreign-key error and preserved parent/child rows; RESTRICT rejected atomically; independent DELETE/INSERT in one transaction rejected as required. These are historical diagnostic results, not a new run or fixed-success proof. The full investigation and attempted executable test construction are recorded in #28026 (comment) and the previous current-main analysis in #28026 (comment) .Current source still calls delete_table then insert_main_table in multi_update.updateOneBatch, exposes data/tombstone batches through ChangesHandle.Next, and reconciles tombstones using their encoded key in findDeleteAndUpdateBat. Inspected producer/frontend/collector files have no diff from the retained diagnostic revision. A moved key has no durable old-to-new association. Timestamp, transaction, order or value matching would conflate the independent-operation counterexample; an output-helper test with invented provenance would bypass the missing producer contract.
Stopping reason: a safe fix requires an approved persistent provenance contract across SQL/CN, storage/recovery and change-stream consumers. The mo-dev design-first gate requires approval before implementing this architectural expansion. Owners must decide representation and atomic publication, update chains/key reuse and PICK selection, historical/mixed-version semantics, checkpoint/compaction/restart preservation, retention/GC bounds and consumer compatibility. Standing implementation permission does not supply those unresolved semantics. Required eventual executable proof includes MERGE/PICK cascade success, native control, RESTRICT and atomicity, independent-operation non-conflation, selection boundaries and restart persistence.
Following the authorized all-members-deferred path: exclude this sole issue from PR delivery and replace severity/s0 with deferred. No production/test changes, commit, push or Draft PR; no claim that the bug is fixed.
gouhongshen commentedon Sep 8, 2026
Revalidated the assignment at freshly fetched
HEAD = origin/main = merge-base = b2f0f3fe69b23cde495c59d226c647aba555cfdc, with a clean worktree. The sole assigned issue is coherent: MERGE and PICK lose the same primary-key-update association.Current-source investigation confirms
multi_update.updateOneBatchcallsdelete_tablefollowed byinsert_main_table; disttae serializes separate insert/delete entries;ChangesHandle.NextandBranchChangeHandleexpose data/tombstone batches without an old-to-new update link.findDeleteAndUpdateBatmatches replacement data by the deleted primary key usingPopByVectorsStream. PICK also filters keys upstream. A move from 2 to 3 cannot be reconstructed safely from this representation.I read the contribution rules, PR template, existing MERGE/PICK FK BVTs, and retained executable diagnostic source and terminal log at revision
f72ca9efbeb3a7c673701e4a135cc6670c33cfde. That test selected five subtests and completed in 17.313s: native UPDATE cascaded; exact MERGE and sibling PICK keys(2) rejected while retaining parent/child state; RESTRICT MERGE rejected atomically; independent DELETE/INSERT in one source transaction also rejected. Public DIFF emitted DELETE 2 plus INSERT 3 for both real UPDATE and independent operations. The full test construction and command are recorded in #28026 (comment) . This is inspected historical diagnostic evidence, not a fresh runtime run at b2f0f3f and not proof of a fix. The inspected producer, serialization, collector, replay and frontend files have no diff from that diagnostic revision.Existing FK BVTs cover stable-key payload changes. A helper test supplied with invented update provenance cannot prove the missing public producer contract. Timestamp, transaction, order or value pairing would conflate the independent-operation counterexample and could trigger unintended cascades; an in-memory association would not establish recovery correctness. No workaround was added.
Stopping reason: the clean solution expands durable/wire contracts across SQL/CN, storage/recovery and change-stream consumers. The mo-dev design-first gate requires an approved versioned design for that architectural expansion. Repository design searches and the issue-related PR search found no approved provenance design; the PR search returns merged #27996, which explicitly excludes this issue. Storage/Data Branch owners must approve identity representation and atomic publication, update chains/key reuse, PICK selection, historical/mixed-version behavior, checkpoint/compaction/restart preservation, retention/GC bounds, consumer compatibility and hot-path costs before implementation.
Required eventual executable proof: exact MERGE/PICK cascade success, native UPDATE control, RESTRICT rejection, failure atomicity, independent DELETE/INSERT non-conflation, key-selection boundaries and persistence/restart preservation. No fixed-success UT/BVT is claimed. Following the authorized all-members-deferred path, exclude #28026 from PR delivery and replace severity/s0 with deferred. No source changes, commit, push or Draft PR.
gouhongshen commentedon Sep 8, 2026
Revalidated this assignment against freshly fetched
HEAD = origin/main = merge-base = b2f0f3fe69b23cde495c59d226c647aba555cfdc; worktree is clean. The design blocker remains, so this sole group member is excluded from PR delivery and deferred.I inspected contribution rules, PR template, current producer/collector/reconciliation code, existing MERGE/PICK foreign-key BVTs, and the retained
TestIssue28026Diagnosticsource and terminal log. Full investigation and test construction: #28026 (comment) . The five diagnostic scenarios atf72ca9efbepassed in 17.313s: native UPDATE cascades; exact MERGE and sibling PICK keys(2) fail with unchanged destination parent/child; RESTRICT rejects atomically; independent DELETE/INSERT in one transaction also rejects. These are historical diagnostic results, not a fresh runtime run or proof of a fix.There is no diff from that diagnostic revision in multi_update, disttae transaction writing, TAE logtail handling, logtail replay partition state, engine change-handle types, BranchChangeHandle, or frontend hashdiff. Current code still deletes then inserts without a durable association, exposes data/tombstone batches, and reconciles by the deleted primary key. Existing FK BVTs test stable-key payload updates. Thus a fabricated helper input cannot prove the missing source-to-apply contract, and timestamp/transaction/order/value pairing would conflate independent operations with UPDATE.
No approved update-provenance design was found in repository design/RFC searches or the issue-related PR search; merged #27996 explicitly excludes this issue. A clean solution changes persistence/wire and cross-owner contracts, triggering
.agents/skills/mo-dev/references/feature-design-review.md: “Require a design when ... changes a public API, client/server or wire protocol, catalog or on-disk format, persistent state ...”. Its required artifact is an approved versioned design before implementation. Storage/Data Branch owners must settle durable identity and atomic publication, chains/key reuse, PICK key selection, historical/mixed-version behavior, checkpoint/compaction/restart preservation, consumer compatibility, retention/GC bounds and hot-path costs.Stopping reason is this unresolved architectural decision, not unavailable test infrastructure. Required eventual proof remains exact MERGE/PICK cascade success, native control, RESTRICT and failure atomicity, independent-operation non-conflation, selection boundaries and persistence/restart. No workaround, production changes, commit, push or Draft PR; restoring
deferredin place ofseverity/s0under the authorized all-members-deferred path.gouhongshen commentedon Sep 8, 2026
Revalidated this sole-issue assignment at freshly fetched
HEAD = origin/main = merge-base = b2f0f3fe69b23cde495c59d226c647aba555cfdc; worktree is clean. The full investigation and executable diagnostic construction remain documented in #28026 (comment) . No implementation is ready for a PR.I reread CONTRIBUTING.md, the PR template, current producer/change-handle/reconciliation code, existing MERGE/PICK FK BVTs, and the retained diagnostic source and terminal log. The historical
TestIssue28026Diagnosticrun atf72ca9efbeselected five scenarios and completed in 17.313s: native UPDATE cascades 2 -> 3; exact MERGE and sibling PICK keys(2) fail with the FK error and preserve destination parent/child rows; RESTRICT rejects atomically; independent DELETE/INSERT in one transaction also rejects. This is inspected historical diagnostic evidence, not a fresh test run or fixed-success proof. The producer, disttae transaction serialization, TAE logtail/replay, engine change-handle interface, BranchChangeHandle and frontend hashdiff paths inspected have no diff from that diagnostic revision.The current root cause remains: multi_update.updateOneBatch deletes then inserts; ChangesHandle.Next exposes data/tombstone batches without a semantic update association; findDeleteAndUpdateBat probes replacement rows using the deleted primary key. PICK filters membership upstream. A real key move and independent DELETE/INSERT cannot safely be distinguished by timestamps, transaction membership, order or values. Existing stable-key FK BVTs and a helper supplied with invented update provenance cannot prove the missing public producer-to-apply contract. No heuristic workaround was implemented.
Repository design/RFC searches and the issue-related PR search found no approved provenance design; the latter returns merged #27996, which explicitly excludes this issue. The clean solution expands persistence/wire and cross-owner contracts. The mo-dev design gate requires an approved versioned design before implementing that expansion. Storage/Data Branch owners must settle durable identity and atomic publication, update chains/key reuse, PICK selection, historical and mixed-version behavior, checkpoint/compaction/restart preservation, retention bounds, consumer compatibility and hot-path cost. These unresolved architectural semantics are the precise stopping reason, not unavailable test infrastructure.
Required eventual proof remains exact MERGE/PICK CASCADE success, native UPDATE control, non-cascade rejection and failure atomicity, independent-operation non-conflation, key-selection boundaries and persistence/restart. No fixed-success UT/BVT is claimed. Under the authorized all-members-deferred path, exclude this sole issue from PR delivery and replace severity/s0 with deferred. No source/test changes, commit, push or Draft PR.
gouhongshen commentedon Sep 9, 2026
Revalidated on current
mainataf965c3e4d86ec218de05b585dbafbedb10aa1aein a fresh embedded single-CN/single-TN/single-Log test instance.I constructed and ran a temporary self-contained SQL probe through
pkg/tests/dml(then removed it, so the worktree remains source-clean):UPDATE parent_t SET id = 4 WHERE id = 2with a child FKON UPDATE CASCADEsucceeds and changeschild_t.parent_idto4.merge_src: 2 -> 3,WHEN CONFLICT ACCEPT) returns the foreign-key error. Parent and child remain2, proving the current failure is atomic.pick_src: 2 -> 3,PICK ... KEYS(2) WHEN CONFLICT ACCEPT) returns the same error and retains the destination parent and child at2.Command:
.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s -run ^TestDataBranchPrimaryKeyUpdateForeignKeyProbe$ ./pkg/tests/dml; selected test passed in 14.345s because it asserts those pre-fix failures and their post-error state.Current ownership analysis confirms this is not safely fixable in frontend apply code:
multi_update.updateOneBatchinvokes delete then insert,ChangesHandle.Nextexposes only independent data and tombstone batches, andfindDeleteAndUpdateBatcan reconcile them only by the deleted primary key. A move2 -> 3therefore loses association. Pairing by timestamp, transaction, or order would conflate an independentDELETE 2plusINSERT 3with UPDATE and could incorrectly execute ON UPDATE actions. An in-memory association would not survive the supported checkpoint/recovery path.The narrowest correct closure is a persistent cross-boundary update-provenance protocol spanning SQL/CN writes, TN/WAL, logtail, checkpoint/replay, and every
CollectChangesconsumer. This changes persistent/wire and distributed recovery contracts, so the design gate requires an approved versioned design. No such design selects the durable old-to-new identity, atomic publication, PICK old-key selection behavior, retention/GC, mixed-version, or restart semantics.I therefore exclude this sole issue from PR delivery and defer it rather than invent an unsafe correlation workaround. Eventual proof must cover MERGE/PICK cascade success, RESTRICT rejection and failure atomicity, independent DELETE/INSERT non-conflation, old-key PICK selection, and checkpoint/restart preservation. No source/test changes, commit, push, or Draft PR were made.
gouhongshen commentedon Sep 9, 2026
Deferred after revalidating the sole assigned member at
HEAD = origin/main = f0c31cd4b830be32442cf329e0a3fb08aa9c16c3. The immediately preceding fresh embedded-cluster probe ataf965c3e4destablished the exact MERGE and sibling PICKkeys(2)failures, atomic destination state, and nativeON UPDATE CASCADEcontrol. The current-head range changes no relevant path:git diff af965c3e..HEAD -- pkg/sql/colexec/multi_update pkg/vm/engine/disttae pkg/vm/engine/tae pkg/vm/engine/change_handle.go pkg/frontend/data_branch* pkg/frontend/databranchutils pkg/cdc pkg/iscp pkg/publication test/distributed/cases/git4data/branchis empty.Current audit still finds delete-then-insert production, data/tombstone-only change handles, and PK-keyed reconciliation. A real key move and an independent DELETE/INSERT cannot be distinguished by timestamp, transaction, order, or value; doing so would spuriously apply FK
ON UPDATEactions. The required durable provenance change crosses CN/TN/WAL, logtail, checkpoint/recovery, and allCollectChangesconsumers. No approved versioned design exists, and the repository design gate blocks such a persistent/distributed protocol change.The prior full reproduction/test-construction record remains valid: #28026 (comment). The issue has been set to
deferred(replacingseverity/s0). No source change, commit, push, or Draft PR is appropriate. Reactivation requires an approved provenance/compatibility design, then executable MERGE/PICK CASCADE, RESTRICT/atomicity, independent-operation non-conflation, and checkpoint/restart proof.gouhongshen commentedon Sep 9, 2026
Revalidated the sole assigned member at HEAD = origin/main = f0c31cd; the worktree is clean. MERGE and PICK remain one coherent missing-provenance problem.
Fresh reproduction and test construction:
Current source confirms why a frontend-only fix is unsafe. multi_update.updateOneBatch deletes before inserting the replacement. engine.ChangesHandle.Next exposes separate data and tombstone batches; BranchChangeHandle forwards them unchanged. findDeleteAndUpdateBat reconstructs an LCA row for a tombstone and probes replacement data by that deleted primary key. A move 2 -> 3 has no association, while an independent DELETE 2 plus INSERT 3 has the same available shape. Timestamp, transaction, order, or value matching would conflate them and could execute unintended ON UPDATE actions.
Existing merge_foreign_key_update and pick_foreign_key_update BVTs cover stable-key payload updates only. A frontend helper supplied with invented provenance would bypass the missing producer-to-consumer contract, so no unsound workaround or non-proving regression was added.
The narrowest correct closure changes persistent/wire and distributed recovery contracts across SQL/CN writes, storage/WAL, logtail/checkpoint replay, and CollectChanges consumers. This triggers the repository design gate. Repository docs/design searches and GitHub PR search found no approved, versioned update-provenance design; the only related PR is merged #27996, whose stated scope explicitly excludes primary-key moves. Required decisions include durable old-to-new identity and atomic publication, update chains/key reuse, PICK old-key selection, checkpoint/restart and mixed-version behavior, retention/GC bounds, consumer compatibility, and hot-path cost.
Stopping reason: the mandatory design is absent, not lack of reproduction or test infrastructure. After an approved design, acceptance evidence must cover MERGE/PICK CASCADE success, native control, RESTRICT rejection and atomicity, independent-operation non-conflation, old-key selection boundaries, and checkpoint/restart persistence. This issue is excluded from PR delivery; no source change, commit, push, or Draft PR is appropriate.
gouhongshen commentedon Sep 9, 2026
Revalidated the sole assigned member at
HEAD = origin/main = e8ae1e51f2b0f04b6d69d37ff6ccf8166736c9e6. The worktree is clean, and thef0c31cd4..HEADrange contains no change in the Data Branch, MULTI_UPDATE, change-handle, storage/replay, or branch BVT paths.Fresh reproduction used a temporary, self-contained embedded single-CN/single-TN/single-Log probe, then removed it. Command:
.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s -run ^TestDataBranchPrimaryKeyUpdateForeignKeyProbe$ ./pkg/tests/dml; it selected five named scenarios and passed in15.660sbecause it asserts current behavior:UPDATE parent SET id = 3 WHERE id = 2withON UPDATE CASCADEupdates the child reference.2 -> 3, and sibling-source PICKKEYS(2), both return a foreign-key error and leave parent and child at2.ON UPDATE RESTRICTrejects atomically.DELETE 2plusINSERT 3in one transaction also returns the FK error and preserves destination state. It must not be reclassified as an update.The production path makes a frontend-only correlation unsafe.
multi_update.updateOneBatchwrites an UPDATE as a delete followed by an insert.engine.ChangesHandle.Nextexposes only independentdataandtombstonebatches, anddatabranchutils.BranchChangeHandleforwards that interface unchanged.findDeleteAndUpdateBatreconstructs the old LCA row from a tombstone, then probes replacement data by the deleted primary key. A key move has old key2and live key3, so it has no association; an independent delete/insert has the same observable shape. Timestamp, transaction, row order, or values are not an operation identity and would spuriously invokeON UPDATEactions. PICK additionally needs an explicit decision whether selecting old key2includes its replacement key3.A correct solution therefore needs durable old-to-new update provenance with atomic publication through CN writes, TN/WAL, logtail, checkpoint/replay, CollectChanges, and every consumer. This is a persistent/wire/distributed-recovery protocol change, which triggers the repository design gate. Searches of
docs/design,docs/rfcs, and related PRs found no approved versioned design for it; merged #27996 explicitly excludes primary-key moves.Blocking design decisions include identity encoding and retention/GC, update chains and key reuse, PICK old-key selection, compatibility and mixed-version behavior, checkpoint/restart/rollback, consumer semantics, and hot-path/resource bounds. Until an approved design resolves these, no safe implementation or executable fixed-success UT/BVT can be delivered. I am excluding this sole issue from PR delivery and replacing
severity/s0withdeferred; no source change, commit, push, or Draft PR is appropriate.gouhongshen commentedon Sep 9, 2026
Triage decision: defer.
Revalidated the sole assigned member at
HEAD = origin/main = 363f8c3fe63ab21f19d8e9ba854c24d2dcaadfc3; the final source diff is empty. I inspected CONTRIBUTING.md, the PR template, current MULTI_UPDATE producer, transaction/change-handle/replay contracts, Data Branch hashdiff/PICK consumers, and the existing stable-key FK BVTs. Merged #27996 explicitly excludes primary-key-changing updates.Fresh executable diagnostic: after building the required native artifacts with
make cgo,.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=300s -run "^TestIssue28026Diagnostic$" ./pkg/tests/dmlpassed in 14.173s. The temporary probe was then removed. Its five assertions prove current behavior:UPDATE parent SET id = 3 WHERE id = 2withON UPDATE CASCADEchanges both parent and child.2 -> 3and sibling-branch PICKKEYS(2)both return an FK error and leave parent/child at2.ON UPDATE RESTRICTrejects atomically.DELETE 2plusINSERT 3also returns the FK error and leaves destination state unchanged.Root cause: an update writes separate delete and insert records.
Transaction.WriteBatchcarries individual operation entries;ChangesHandle.Nextexports only a data batch and a tombstone batch. Replay emits data as rowid + values + commit timestamp and tombstones as rowid + primary key + timestamp.BranchChangeHandleforwards that interface, andfindDeleteAndUpdateBatprobes candidate replacements by the deleted primary key. The key move has deleted key2and live key3, so it has no link; independent DELETE/INSERT has the same observable shape. Timestamp, transaction, order, or values are not an operation identity and would incorrectly turn real deletes into FK-cascading updates.A safe fix therefore requires durable old-to-new provenance with atomic publication through CN writes, storage/WAL, logtail/checkpoint replay,
CollectChanges, and all consumers. This changes persistent and distributed-recovery contracts, triggering the design gate. Repository design/RFC searches and related-PR search found no approved versioned design. Blocking decisions include identity encoding and retention/GC, update chains/key reuse, PICK old-key selection, mixed-version and historical behavior, checkpoint/restart/rollback, consumer compatibility, and hot-path bounds.No heuristic workaround or failing-behavior regression was retained. To promote later: approve that design, then prove MERGE/PICK CASCADE success, native controls, RESTRICT failure atomicity, independent-operation non-conflation, key-selection boundaries, and checkpoint/restart persistence. This issue has no source change, commit, push, or PR.
gouhongshen commentedon Sep 9, 2026
Triage decision: defer.
I revalidated the sole assigned issue at
HEAD = origin/main = 363f8c3fe63awith a clean worktree. The latest current-head executable diagnostic is reusable: its exact storage/Data Branch source closure is unchanged, and its five public assertions establish that nativeUPDATE id=2 -> 3withON UPDATE CASCADEsucceeds, while the exact Data Branch MERGE and sibling-branch PICKKEYS(2)both fail atomically with the parent and child retained at2; native RESTRICT also rejects atomically; and an independent sourceDELETE 2plusINSERT 3in one transaction has the same failing Data Branch behavior. The temporary diagnostic was deliberately removed because it only asserts the unfixed behavior and cannot be a regression proof for a future fix.The root cause is unchanged.
multi_update.updateOneBatchwrites DELETE and INSERT separately. Insert writes allocate a new physical RowID. The transport converts writes only to insert/delete entries; partition-state replay supports insert/delete rather than a user-row update record; andChangesHandle.Nextexposes only data and tombstone batches.findDeleteAndUpdateBatreconstructs the LCA row from the tombstone and probes candidate replacement data by that deleted primary key. A key move has tombstone key2and data key3, so it has no association. An independent DELETE/INSERT has the same observable shape.Correlating by timestamp, transaction, stream order, or value would therefore manufacture UPDATE semantics and could trigger an unintended
ON UPDATEaction. An in-memory marker would not survive logtail/checkpoint/replay. Searches ofdocs/design,docs/rfcs, and related Data Branch work found no approved durable update-provenance design.A safe implementation needs an approved persistent old-to-new provenance contract spanning CN writes, TN/WAL, logtail, checkpoint/replay,
CollectChanges, and its consumers; it must also define retention/GC, update chains/key reuse, PICK old-key selection, mixed-version/history behavior, failure atomicity, and resource bounds.To promote later: approve that contract, then add fixed-success MERGE/PICK CASCADE BVTs plus RESTRICT atomicity, independent DELETE/INSERT non-conflation, selection-boundary, and restart/checkpoint coverage. No focused PR, commit, or source change is safe before that decision.
gouhongshen commentedon Sep 9, 2026
Triage decision: defer.
I revalidated the sole assigned issue at HEAD = origin/main = cd04bb4. The worktree is source-clean. I read CONTRIBUTING.md, the PR template, the current MULTI_UPDATE producer, the persisted tombstone and replay/change-handle contracts, Data Branch hashdiff and PICK paths, and the nearby stable-key foreign-key BVTs. The merged #27996 scope explicitly excludes primary-key moves.
Fresh executable evidence was obtained on this exact head with an isolated embedded single-CN/single-TN/single-Log instance built from this worktree. I ran a self-contained temporary BVT through mo-tester, inspected its generated result statement by statement, then ran the same case in normal comparison mode. The case proves all of the following current behaviors:
Current source confirms why frontend-only repair is not sound. multi_update.updateOneBatch emits delete_table followed by insert_main_table. The tombstone contract persists only old RowID, old primary key, and commit metadata, while the replacement is an ordinary new data row. ChangesHandle and BranchChangeHandle expose independent data and tombstone batches. findDeleteAndUpdateBat and buildHashmapForTable correlate using the primary-key value; a tombstone at 2 cannot identify data at 3. The observed public diff is identical for the real UPDATE and the independent delete/insert counterexample. Timestamp, transaction membership, order, or values are not a durable operation identity and would manufacture UPDATE semantics, including unintended cascades.
The narrowest correct change introduces durable old-to-new provenance and atomic publication across SQL/CN writes, storage/WAL, logtail, checkpoint/replay, CollectChanges, and its consumers. That changes persistent and cross-owner change-stream contracts, meeting the repository design-gate trigger. Searches of docs/design, docs/rfcs, and related PRs found no approved versioned provenance design. The required design decisions include identity representation and retention/GC, update chains and key reuse, PICK selection by old key, historical and mixed-version behavior, restart/checkpoint/rollback, consumer compatibility, and hot-path resource bounds.
This missing approved protocol decision is the precise stopping reason. No heuristic or fabricated helper provenance was added, because it could not be a valid fixed-success regression. After design approval, executable acceptance must cover MERGE/PICK CASCADE success, native control, RESTRICT rejection and failure atomicity, independent-operation non-conflation, key-selection boundaries, and persistence/restart. This sole issue is excluded from PR delivery; no source change, commit, push, or Draft PR is appropriate.
gouhongshen commentedon Oct 28, 2026
PR #31629 is trying to fix this issue.