You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: DATA BRANCH MERGE fails with misleading 'legacy ALTER' lineage error after unqualified DELETE on target #29886
After an unqualifiedDELETE FROM <target> on the merge target, DATA BRANCH MERGE fails with a misleading error even though no ALTER was ever executed:
ERROR 20101 (HY000): internal error: data branch: schema-evolution lineage metadata is missing for a legacy ALTER; recreate the branch before DIFF/MERGE
The same scenario with DELETE ... WHERE id>0 (deleting the same rows) merges fine and yields the expected 1 row. Likely the unqualified DELETE is executed as a truncate/table rebuild that changes the table id and breaks branch lineage.
Expected Behavior
Merge succeeds (result: only row 9), exactly as with DELETE ... WHERE id>0. If a rebuild truly breaks lineage, the error should say that (e.g. "table was truncated/rebuilt after branch creation") instead of mentioning an ALTER the user never ran.
Steps to Reproduce
dropdatabase if exists ki; create database ki; use ki;
createtabledocs(id intprimary key, v int); insert into docs values(1,1),(2,2);
data branch create table docs_dev from docs; insert into docs_dev values(9,9);
deletefrom docs; -- no WHERE
data branch merge docs_dev into docs; -- ERROR 20101 ... legacy ALTER-- controlcreatetabled2(id intprimary key, v int); insert into d2 values(1,1),(2,2);
data branch create table d2_dev from d2; insert into d2_dev values(9,9);
deletefrom d2 where id>0;
data branch merge d2_dev into d2; selectcount(*) from d2; -- 1, OK
Reproduced 3/3 (two fresh containers).
Additional information
Error raised in pkg/frontend/data_branch.go (dataBranchLineageTableID → legacy alias check). Found during internal benchmarking of data-branch features.
This issue requires human involvement and cannot currently be completed independently by the
automated fix loop.
Reason
The remaining blocker is out of this worktree's reach, not unproven: issue #29886 is reported against v4.2.5, whose TruncateTable rebuild still drops and recreates the physical table without publishing the successor generation edge (cached origin/4.2-dev pkg/sql/compile/ddl.go), so the reporter's exact failure persists there until the #28148 rebuild-lineage protocol (edge publication, postponed replacement-DROP reclaim, protection snapshot, shared retire/reclaim helper, with the maintenance branch's existing ALTER lineage helpers and current lifecycle corrections) is adapted to the 4.2 maintenance line and proven with the original reproduction failing before and returning exactly (9,9) after. The handler skill confines work to the supplied worktree, which is main-based (02a2823), and main already contains that protocol, so the backport cannot be produced or tested from here without creating a new worktree, which this loop forbids. The main-side deliverable in this worktree is complete and re-verified after fixing review finding 1 (component-ownership discriminator, level preservation, counterexample and decideLCA regressions, 110/110 new BVT, 6233-statement branch suite, 2501-statement clone suite, owning UTs, negative control) and can be shipped as a separate main PR, but per the reviewer it does not close the reported environment. Next human action: supply a 4.2-dev-based worktree/job for the backport (or accept the main-only residual fix as a separate PR explicitly not closing this issue), and post the deferral analysis plus the severity/s0 -> deferred label change on the issue, which this session could not do for lack of GitHub tools.
Evidence
{
"ready_for_review": false,
"summary": "Revision after the rejected pre-PR review, on the same main-based worktree (agent/issue-29886-6f877350 at 02a2823, uncommitted diff preserved). Review finding 1 (subtree-only liveness let genuine lineage loss through) was verified valid and fixed: dataBranchLineageTableID now flags a rebuilt endpoint only when live lineage still owns the retained rows - a live descendant in the subtree, or a live logical branch anywhere in the connected component, which is the ownership rule ComputeAlterLineageCompactionPlan itself uses - so a fully reclaimed generation group (subtree dead AND component without a live logical branch) still resolves by its own physical id, while an old-version rebuild that retired the branch row without publishing a successor edge beside a live sibling branch is rejected with the operation-neutral diagnostic instead of silently merging with no common ancestor. constructBranchDAGWithLock now preserves the level string into DataBranchMetadata so the reclaim projection's logical-branch ownership test is faithful (the review's 'preserve required metadata fields'). New UTs cover the reviewer's exact counterexample, the fully-reclaimed-with-siblings pass case, and the plain-alter historical-pin boundary; a new decideLCABranchTSFromBranchDAG-level regression fed a mocked mo_branch_metadata result set proves the rejection fires before the no-LCA fallback and that the fully reclaimed state keeps no-common-ancestor semantics. A negative control (discriminator temporarily reverted to subtree-only) makes both new tests fail exactly as the review predicted, then passes again after restoring the fix. Everything was re-verified end to end: owning UTs pass, make build exits 0, the reporter's script returns exactly (9,9) on the patched build, the post-reclaim probe merges to (3,3),(4,4), and the new BVT case (110/110), git4data/branch/metadata (310/310), git4data/branch (6213 success of 6233, 0 failed, 20 ignored), and git4data/clone (2501/2501) all pass with CI flags. Review finding 2 was verified but is undeliverable from this worktree: the reporter's v4.2.5 environment needs the #28148 rebuild-lineage protocol backported to the 4.2 maintenance line, and the handler skill restricts work to the supplied main-based worktree, so the group is reported not ready rather than claiming completion.",
"reproduction": {
"method": "Local single-node mo-service built from this worktree (make build; select version() = 8.0.30-MatrixOne-v298866877350) launched from /tmp/mo-29886-v2/launch.toml on a fresh DISK-V2 store, frontend 127.0.0.1:6002, with log/tn/cn ports shifted off a sibling worktree's service sharing this machine; ad-hoc SQL via /opt/homebrew/opt/mysql-client/bin/mysql -u root -p111, BVT via the scratch mo-tester runner /tmp/mo-tester-29886b (mo-tester repo untouched) with the CI flags -n -g -o from optools/run_bvt_group.sh; UTs via ./.agents/skills/mo-dev/scripts/mo-cgo-test. Service logs, BVT logs and per-suite report copies are under /tmp/mo-29886-v2/.",
"steps": [
"Run the issue's script verbatim (/tmp/mo-29886/repro.sql): create docs, branch docs_dev, insert (9,9), unqualified delete from docs, data branch merge docs_dev into docs, select; plus the delete-where-id>0 control on d2.",
"Run the residual-main reclaim path (/tmp/mo-29886/probe8.sql): rebuild t via unqualified DELETE, delete the only branch to trigger reclaim, dump mo_branch_metadata/rel_logical_id, then merge an unrelated branch into t.",
"UTs: mo-cgo-test -count=1 ./pkg/frontend/databranchutils/; -run 'TestDataBranchLineageTableIDResolution|TestDataBranchRebuildLineageMissingErrorIsOperationNeutral|TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback' ./pkg/frontend/ (verbose to confirm every new subtest executes); -run 'Branch|Lineage|Subtree|Clone|Snapshot|Reclaim' ./pkg/frontend/.",
"Negative control for finding 1: temporarily restore the rejected subtree-only condition in dataBranchLineageTableID, rerun the two new tests (expected failures), then restore the fix and rerun (pass).",
"BVT with CI flags: -i branch_merge_target_rebuild; -i git4data/branch/metadata; -i git4data/branch; -i git4data/clone."
],
"baseline": "Three baselines. (1) Reporter's v4.2.5 image: the literal script fails with ERROR 20101 'legacy ALTER' because 4.2-dev's TruncateTable path (pkg/sql/compile/ddl.go) still rebuilds with LogicalId preserved and no successor edge - established by the review's cached-branch inspection and the prior round's analysis; not buildable from this worktree. (2) Main-residual path on the unpatched build of this worktree (prior round, change stashed): probe8's post-reclaim merge failed with the exact reported error and the new BVT scored 104/110 with that message at rows 191-193 and 261-263. (3) This round's finding-1 baseline: with the rejected patch's subtree-only discriminator temporarily restored, 'old-version rebuild beside a live sibling branch' fails (endpoint resolved as physical id 20, want flagged lineage id 10) and 'live sibling keeps the component owned' fails with 'An error is expected but got nil' - the silent no-common-ancestor merge the reviewer's counterexample predicted; both pass again after the fix is restored.",
"expected": "The reporter's exact scenario merges to exactly row (9,9) with docs_dev unchanged; a rebuilt target whose lineage descendants were all reclaimed behaves as an ordinary table and merges an unrelated branch to exactly (3,3),(4,4); an old-version rebuild state whose component still has a live logical branch is rejected with an error that says the table was rebuilt and names the endpoint, never mentioning ALTER; genuinely missing lineage is never silently merged as unrelated.",
"observed": "Patched build: repro.sql returns exactly (9,9) for docs after the merge in both the reported case and the predicate control, docs empty before the merge, docs_dev unchanged at (1,1),(2,2),(9,9), and the catalogue shows the live successor edge (level 'alter', p_table_id=old gen). probe8 leaves only the retired branch row after reclaim and the unrelated-branch merge yields exactly (3,3),(4,4). UTs: all focused and owning selections pass, including the new counterexample cases (verbose run listed all subtests). Negative control reproduced the two predicted failures on pre-fix code. BVT: branch_merge_target_rebuild 110/110 (100%); git4data/branch/metadata 310/310; git4data/branch TOTAL 6233, SUCCESS 6213, FAILED 0, IGNORED 20 (the pre-existing @bvt:issue#24840 blocks), ABNORMAL 0; git4data/clone 2501/2501, FAILED 0."
},
"root_cause": "The reported symptom has two layers. (1) On the reporter's v4.2.5 line, a predicate-free DELETE is rewritten into Scope.TruncateTable, a copy-and-swap rebuild that replaces rel_id while preserving rel_logical_id but publishes no successor edge in mo_branch_metadata; dataBranchLineageTableID then saw the physical id absent from the DAG with the LogicalId present and decideLCABranchTSFromBranchDAG rejected DIFF/MERGE with the ALTER-specific message. Current main already publishes the successor edge plus protection snapshot via #28148, so the literal script passes there. (2) The defect still live on main was the discriminator: constructBranchDAGWithLock reads every metadata row without filtering table_deleted, so after DATA BRANCH DELETE reclaims the last live descendant the replaced generation stays a DAG node through the retired branch row while the rebuilt physical id is absent, and the old 'LogicalId in DAG' rule produced the same misleading error for an ordinary table. The first patch fixed that with a subtree-liveness test, and the review then correctly identified its residual gap, now confirmed in code: SubtreeHasLiveNode(LogicalId) is false for an old-version rebuild that retired the branch row without publishing the successor edge while a sibling branch keeps the component alive, because subtree liveness never crosses the shared ancestor; the endpoint then resolved as an unrelated table and decideLCABranchTSFromBranchDAG silently applied no-common-ancestor merge semantics. The correct discriminator is the ownership rule of the reclaim lifecycle itself: alter-lineage compaction retains every row of a connected component that still has a live logical branch (branch_protect_snapshot.go connectedComponent/ComponentHasLiveLogicalBranch), so only a component with no live logical branch anywhere - and no live descendant in the subtree - is legitimately detached; anything else means the missing successor edge is genuine lineage loss that must be rejected. Additionally, the first patch dropped the level column when projecting the metadata read, which would have made every live row (including plain 'alter' pins) look like a logical branch owner to that component test; the level string is now preserved.",
"changes": [
"pkg/frontend/data_branch.go dataBranchLineageTableID: an endpoint whose current physical generation is absent from the lineage while its LogicalId is a node is now flagged only when live lineage still owns the retained rows - lineage.SubtreeHasLiveNode(LogicalId) or the new lineage.ComponentHasLiveLogicalBranch(LogicalId); a fully reclaimed generation group resolves by its own physical id. Comment documents the old-version sibling-branch case and the compaction ownership rule.",
"pkg/frontend/data_branch.go constructBranchDAGWithLock: the mo_branch_metadata row mapping now carries the level string into DataBranchMetadata.Level (in addition to the derived LineageOnly) so the reclaim projection's isLogicalBranchOwnerLevel test sees the real level instead of treating every live row as a logical branch.",
"pkg/frontend/databranchutils/branch_dag.go: BranchLineage.ComponentHasLiveLogicalBranch delegates to the existing BranchReclaimDag.ComponentHasLiveLogicalBranch, keeping the LCA DAG and both liveness projections derived from one catalogue read with no new scan.",
"pkg/frontend/data_branch.go decideLCABranchTSFromBranchDAG + dataBranchRebuildLineageMissingError + constructBranchDAG/ForUpdate returning BranchLineage, and pkg/frontend/clone.go revalidation closure using lineage.DAG: carried over from the prior round (operation-neutral diagnostic naming every affected endpoint; single-read projection; behavior-preserving clone adaptation).",
"pkg/frontend/data_branch_hashdiff_test.go: TestDataBranchLineageTableIDResolution gains 'old-version rebuild beside a live sibling branch' (flagged), 'whole component reclaimed including siblings' (resolves by physical id), and 'historical pin without a live logical branch' (live plain-alter row does not own the component), with explicit level strings on all fixture rows; new newMrsForBranchMetadataDAG helper builds the branchDAGSelectSQL-shaped result set; new TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback drives decideLCABranchTSFromBranchDAG through a mocked BackgroundExec and asserts the sibling-alive state returns exactly dataBranchRebuildLineageMissingError("db1.docs") with lcaTableId 0, while the fully retired state returns nil error with the synthetic single-node path [20].",
"pkg/frontend/databranchutils/branch_dag_test.go TestBranchLineageProjectsOneRead: extended with component-projection assertions for the retired-child-with-live-sibling case, the whole-component-retired case, the plain-alter historical-pin split, and the empty lineage.",
"test/distributed/cases/git4data/branch/metadata/branch_merge_target_rebuild.sql and .result: unchanged this round (110 statements; issue repro with catalogue assertions, both controls, repeated rebuilds, single- and two-generation reclaim counterexamples, same-name DROP/CREATE counterexample) and re-verified against the revised build."
],
"tests": [
"make build -> exit 0 (mo-service relinked, version 8.0.30-MatrixOne-v298866877350); gofmt -l on all five touched Go files -> clean.",
"./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/frontend/databranchutils/ -> ok 3.177s (whole package, including the extended TestBranchLineageProjectsOneRead).",
"./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run 'TestDataBranchLineageTableIDResolution|TestDataBranchRebuildLineageMissingErrorIsOperationNeutral|TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback' ./pkg/frontend/ -> ok 3.176s; verbose rerun listed all nine resolution subtests and both decideLCA subtests as PASS.",
"./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run 'Branch|Lineage|Subtree|Clone|Snapshot|Reclaim' ./pkg/frontend/ -> ok 2.807s.",
"Negative control (finding 1): with the subtree-only condition temporarily restored, TestDataBranchLineageTableIDResolution/old-version_rebuild_beside_a_live_sibling_branch FAILS (expected lineage id 0xa, actual 0x14) and TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback/live_sibling_keeps_the_component_owned FAILS ('An error is expected but got nil'); fix restored, both pass.",
"Ad-hoc SQL on the patched build: /tmp/mo-29886/repro.sql -> docs exactly (9,9) after the merge in both the reported case and the predicate control, docs_dev unchanged; /tmp/mo-29886/probe8.sql -> after DATA BRANCH DELETE reclaim only the retired branch row remains (alter edge gone) and merging the unrelated branch yields exactly (3,3),(4,4).",
"BVT (scratch runner, CI flags -n -g -o): -i branch_merge_target_rebuild -> TOTAL 110, SUCCESS 110, FAILED 0, 100%.",
"BVT: -i git4data/branch/metadata -> TOTAL 310, SUCCESS 310, FAILED 0, 100%.",
"BVT: -i git4data/branch -> TOTAL 6233, SUCCESS 6213, FAILED 0, IGNORED 20, ABNORMAL 0, 100% (includes branch_rebuild_lifecycle and every diff/merge/pick/protect/privilege case); an earlier attempt of this suite was invalidated when an external SIGTERM killed the service mid-run (its 5095 ABNORMAL statements were connection losses, FAILED 0) and was rerun to completion after relaunching the service detached.",
"BVT: -i git4data/clone -> TOTAL 2501, SUCCESS 2501, FAILED 0, 100% (covers the clone.go call site); error.txt empty for all passing runs."
],
"proof": [
"Reviewer counterexample closed at three levels: the pure projection (SubtreeHasLiveNode(10)=false while ComponentHasLiveLogicalBranch(10)=true beside a live sibling), the endpoint resolver (lineage id 10 + qualified name 'db1.docs' returned), and decideLCABranchTSFromBranchDAG through a mocked metadata read (exact dataBranchRebuildLineageMissingError text, lcaTableId 0) - DIFF/MERGE rejects the missing ancestry instead of converting it into a no-common-ancestor merge.",
"The negative control proves these tests detect the rejected patch's defect: on subtree-only code the sibling-alive endpoint resolved as physical id 20 and decideLCA returned nil, which was the silent wrong merge; the restored component rule rejects it.",
"The legitimate reclaim family still passes: 'whole component reclaimed including siblings' resolves by physical id at UT level, and the BVT's single-generation and two-generation reclaim sections still DIFF/MERGE to exactly (3,3),(4,4) after reclaim, so distinguishing genuine loss did not reintroduce the original false positive.",
"The rule matches the compaction ownership split, not mere row presence: 'historical pin without a live logical branch' (live plain-alter row, all logical branches retired) still resolves by physical id, pinned by UT on both projections.",
"The level-string preservation is load-bearing and covered: the ownership test reads DataBranchMetadata.Level, and the fixtures use real levels ('table', 'alter'), so a regression that drops the level again would flip the component verdicts in TestBranchLineageProjectsOneRead.",
"No regression on owning surfaces: full git4data/branch (6233 statements), git4data/branch/metadata (310), git4data/clone (2501) and the new 110-statement case all pass with CI flags; focused and broader frontend/databranchutils UT selections pass; make build and gofmt clean.",
"Reporter's exact script on the patched build yields exactly (9,9) with docs_dev unchanged, and the predicate control is identical, which is the issue's stated expected behavior for the merge semantics this worktree can deliver."
],
"risks": [
"Scope boundary (review finding 2): the reporter's v4.2.5 image is fixed only by backporting the #28148 rebuild-lineage publication protocol to the 4.2 maintenance line; this loop supplied a main-based worktree and the handler skill restricts work to it, so that backport is not delivered here and the issue group must not be marked complete on this change alone.",
"The skill's deferred path asks for an issue comment and replacing severity/s0 with deferred; no GitHub tools are available in this session (MCP search returned none), so neither action was performed - the controller or a later turn must do it.",
"The reworded diagnostic's fire path is not reachable through ordinary SQL on patched main (a successor edge is always published while a live descendant exists, and old-version metadata cannot be created by SQL on this build), so it is proven by the mocked decideLCABranchTS regression rather than a BVT error assertion.",
"The worktree HEAD is 38 commits behind origin/main and fast-forwardable; the rebase belongs to the PR-creation turn. No commit, push, branch, or PR was created and nothing was staged.",
"Verification environment notes: a sibling worktree's mo-service shares this machine (ports were shifted; logs under /tmp/mo-29886-v2), one earlier suite attempt was invalidated by an external SIGTERM and rerun cleanly, and the scratch service was shut down (graceful 'Shutdown complete') after verification; restart with ./mo-service -launch /tmp/mo-29886-v2/launch.toml (~30s on the bootstrapped store; dump user already created).",
"Extra cost is one O(rows) component walk per DIFF/MERGE endpoint whose current generation is absent from the lineage (the already-fetched rows); no additional catalogue read, lock, or transaction was added."
],
"deferred_reason": "The remaining blocker is out of this worktree's reach, not unproven: issue #29886 is reported against v4.2.5, whose TruncateTable rebuild still drops and recreates the physical table without publishing the successor generation edge (cached origin/4.2-dev pkg/sql/compile/ddl.go), so the reporter's exact failure persists there until the #28148 rebuild-lineage protocol (edge publication, postponed replacement-DROP reclaim, protection snapshot, shared retire/reclaim helper, with the maintenance branch's existing ALTER lineage helpers and current lifecycle corrections) is adapted to the 4.2 maintenance line and proven with the original reproduction failing before and returning exactly (9,9) after. The handler skill confines work to the supplied worktree, which is main-based (02a2823), and main already contains that protocol, so the backport cannot be produced or tested from here without creating a new worktree, which this loop forbids. The main-side deliverable in this worktree is complete and re-verified after fixing review finding 1 (component-ownership discriminator, level preservation, counterexample and decideLCA regressions, 110/110 new BVT, 6233-statement branch suite, 2501-statement clone suite, owning UTs, negative control) and can be shipped as a separate main PR, but per the reviewer it does not close the reported environment. Next human action: supply a 4.2-dev-based worktree/job for the backport (or accept the main-only residual fix as a separate PR explicitly not closing this issue), and post the deferral analysis plus the severity/s0 -> deferred label change on the issue, which this session could not do for lack of GitHub tools.",
"issue_reports": [
{
"number": 29886,
"reproduction": {
"method": "Local single-node mo-service built from this worktree (make build; version 8.0.30-MatrixOne-v298866877350) on /tmp/mo-29886-v2/launch.toml, frontend 127.0.0.1:6002 on a fresh DISK-V2 store; SQL via mysql client, BVT via scratch mo-tester /tmp/mo-tester-29886b with CI flags -n -g -o; UTs via ./.agents/skills/mo-dev/scripts/mo-cgo-test.",
"steps": [
"Issue script verbatim (/tmp/mo-29886/repro.sql): unqualified DELETE on the merge target then DATA BRANCH MERGE, select id,v; plus the delete-where-id>0 control.",
"Residual-main reclaim path (/tmp/mo-29886/probe8.sql): rebuild t, delete its only branch (reclaim), then merge an unrelated branch into t.",
"UT matrix incl. the review counterexample (rows {10->1 deleted, 11->1 live}, endpoint physical 20 / LogicalId 10) and the fully-reclaimed variant.",
"Negative control: temporarily restore the subtree-only discriminator, rerun the new tests, restore the fix.",
"BVT: -i branch_merge_target_rebuild; -i git4data/branch/metadata; -i git4data/branch; -i git4data/clone."
],
"baseline": "Reporter's v4.2.5 image fails the literal script with ERROR 20101 'legacy ALTER' (4.2-dev publishes no successor edge; established by cached-branch inspection, not buildable from this worktree). Unpatched main of this worktree passes the literal script (#28148 present) but fails the post-reclaim path with the same reported error (probe8, prior round; BVT 104/110 at rows 191-193/261-263). Rejected-patch baseline this round: the sibling-alive old-version state resolves as an unrelated table and decideLCA returns nil instead of the rejection - the review's finding 1, reproduced by the negative control.",
"expected": "Merge succeeds with exactly (9,9) and the branch unchanged; reclaimed-generation targets behave as ordinary tables merging an unrelated branch to exactly (3,3),(4,4); genuine lineage loss (live descendant, or live logical branch anywhere in the component) is rejected with an operation-neutral rebuilt-table diagnostic naming the endpoint; predicate and rewrite-disabled DELETE controls behave identically to the unqualified case.",
"observed": "All observed on the patched build: repro returns exactly (9,9) both cases with docs_dev unchanged and a live level-'alter' successor edge in the catalogue; probe8's post-reclaim merge returns exactly (3,3),(4,4) with only the retired branch row remaining; the sibling-alive UT cases flag the endpoint and decideLCA returns exactly the operation-neutral error; the fully-reclaimed cases resolve by physical id with no-LCA semantics; BVT 110/110, 310/310, 6213/6233 (0 failed, 20 pre-existing ignored), 2501/2501; owning UTs pass; negative control confirms the new tests fail on the pre-fix discriminator."
},
"root_cause": "Predicate-free DELETE is rewritten into Scope.TruncateTable, a copy-and-swap rebuild that replaces rel_id while preserving rel_logical_id. On 4.2 no successor edge is published, so dataBranchLineageTableID saw the physical id absent with the LogicalId present and rejected DIFF/MERGE with the ALTER-specific message. Main already publishes the edge via #28148; its residual defect was the discriminator itself, which treated any retired-row-backed DAG membership as lineage loss after reclaim. The rejected fix's subtree-liveness test then under-rejected: an old-version rebuild that retires the branch row without a successor edge while a sibling branch keeps the connected component alive has a dead subtree, so the endpoint resolved as an unrelated table and merged with no common ancestor. The correct rule is the reclaim lifecycle's own ownership semantics: only a connected component with no live logical branch anywhere (and no live subtree descendant) is legitimately detached; otherwise the missing successor edge is genuine lineage loss that must be rejected, and the level string must survive the metadata projection for that ownership test to be faithful.",
"changes": [
"dataBranchLineageTableID flags an endpoint only when SubtreeHasLiveNode(LogicalId) or ComponentHasLiveLogicalBranch(LogicalId) - the compaction ownership rule - so fully reclaimed groups resolve by physical id and sibling-alive old-version states are rejected.",
"constructBranchDAGWithLock preserves the level string into DataBranchMetadata.Level for the reclaim projection.",
"BranchLineage.ComponentHasLiveLogicalBranch added, delegating to the existing BranchReclaimDag rule with no second catalogue scan.",
"Prior-round changes retained: operation-neutral dataBranchRebuildLineageMissingError naming every endpoint, BranchLineage single-read projection through constructBranchDAG/ForUpdate and clone.go, 110-statement BVT pair.",
"Tests: counterexample, whole-component-reclaimed, and historical-pin resolution cases; decideLCABranchTSFromBranchDAG regression with mocked metadata (rejection precedes the no-LCA fallback; fully retired state keeps no-LCA semantics); component-projection assertions in TestBranchLineageProjectsOneRead."
],
"tests": [
"mo-cgo-test -count=1 ./pkg/frontend/databranchutils/ -> ok 3.177s.",
"mo-cgo-test -count=1 -run 'TestDataBranchLineageTableIDResolution|TestDataBranchRebuildLineageMissingErrorIsOperationNeutral|TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback' ./pkg/frontend/ -> ok (verbose: all subtests PASS).",
"mo-cgo-test -count=1 -run 'Branch|Lineage|Subtree|Clone|Snapshot|Reclaim' ./pkg/frontend/ -> ok 2.807s.",
"Negative control: two new tests fail on the temporarily restored subtree-only discriminator, pass after the fix.",
"make build exit 0; gofmt clean on all five touched files.",
"BVT CI flags: branch_merge_target_rebuild 110/110; git4data/branch/metadata 310/310; git4data/branch 6213/6233 SUCCESS with 0 FAILED/20 IGNORED/0 ABNORMAL; git4data/clone 2501/2501.",
"Ad-hoc: repro.sql -> exactly (9,9) both cases; probe8.sql -> post-reclaim merge exactly (3,3),(4,4)."
],
"proof": [
"The reviewer's counterexample is now rejected at projection, resolver, and decideLCABranchTS levels, with the exact operation-neutral error text asserted, and the negative control proves these tests catch the previous defect.",
"Legitimate reclaim still passes: UT whole-component case and the BVT single-/two-generation reclaim sections (exactly (3,3),(4,4)), so the false-positive fix is preserved.",
"The compaction ownership split is pinned: a live plain-alter historical pin does not own the component, matching ComputeAlterLineageCompactionPlan's live-logical-branch rule.",
"Reporter's script yields exactly (9,9) with the branch unchanged on the patched build; controls identical.",
"No owning-surface regression: 6233-statement branch suite, 310-statement metadata suite, 2501-statement clone suite, and all focused UT selections pass with CI flags; the reporter's v4.2.5 environment itself remains unfixed pending the 4.2 backport, which this main-based worktree cannot produce."
]
}
]
}
Please use this analysis to provide the missing decision, environment, evidence, or ownership
needed before the issue is returned to the AI candidate pool.
Activity
gouhongshen commentedon Oct 12, 2026
Automated AI triage
This issue requires human involvement and cannot currently be completed independently by the
automated fix loop.
Reason
The remaining blocker is out of this worktree's reach, not unproven: issue #29886 is reported against v4.2.5, whose TruncateTable rebuild still drops and recreates the physical table without publishing the successor generation edge (cached origin/4.2-dev pkg/sql/compile/ddl.go), so the reporter's exact failure persists there until the #28148 rebuild-lineage protocol (edge publication, postponed replacement-DROP reclaim, protection snapshot, shared retire/reclaim helper, with the maintenance branch's existing ALTER lineage helpers and current lifecycle corrections) is adapted to the 4.2 maintenance line and proven with the original reproduction failing before and returning exactly (9,9) after. The handler skill confines work to the supplied worktree, which is main-based (02a2823), and main already contains that protocol, so the backport cannot be produced or tested from here without creating a new worktree, which this loop forbids. The main-side deliverable in this worktree is complete and re-verified after fixing review finding 1 (component-ownership discriminator, level preservation, counterexample and decideLCA regressions, 110/110 new BVT, 6233-statement branch suite, 2501-statement clone suite, owning UTs, negative control) and can be shipped as a separate main PR, but per the reviewer it does not close the reported environment. Next human action: supply a 4.2-dev-based worktree/job for the backport (or accept the main-only residual fix as a separate PR explicitly not closing this issue), and post the deferral analysis plus the severity/s0 -> deferred label change on the issue, which this session could not do for lack of GitHub tools.
Evidence
{
"ready_for_review": false,
"summary": "Revision after the rejected pre-PR review, on the same main-based worktree (agent/issue-29886-6f877350 at 02a2823, uncommitted diff preserved). Review finding 1 (subtree-only liveness let genuine lineage loss through) was verified valid and fixed: dataBranchLineageTableID now flags a rebuilt endpoint only when live lineage still owns the retained rows - a live descendant in the subtree, or a live logical branch anywhere in the connected component, which is the ownership rule ComputeAlterLineageCompactionPlan itself uses - so a fully reclaimed generation group (subtree dead AND component without a live logical branch) still resolves by its own physical id, while an old-version rebuild that retired the branch row without publishing a successor edge beside a live sibling branch is rejected with the operation-neutral diagnostic instead of silently merging with no common ancestor. constructBranchDAGWithLock now preserves the level string into DataBranchMetadata so the reclaim projection's logical-branch ownership test is faithful (the review's 'preserve required metadata fields'). New UTs cover the reviewer's exact counterexample, the fully-reclaimed-with-siblings pass case, and the plain-alter historical-pin boundary; a new decideLCABranchTSFromBranchDAG-level regression fed a mocked mo_branch_metadata result set proves the rejection fires before the no-LCA fallback and that the fully reclaimed state keeps no-common-ancestor semantics. A negative control (discriminator temporarily reverted to subtree-only) makes both new tests fail exactly as the review predicted, then passes again after restoring the fix. Everything was re-verified end to end: owning UTs pass, make build exits 0, the reporter's script returns exactly (9,9) on the patched build, the post-reclaim probe merges to (3,3),(4,4), and the new BVT case (110/110), git4data/branch/metadata (310/310), git4data/branch (6213 success of 6233, 0 failed, 20 ignored), and git4data/clone (2501/2501) all pass with CI flags. Review finding 2 was verified but is undeliverable from this worktree: the reporter's v4.2.5 environment needs the #28148 rebuild-lineage protocol backported to the 4.2 maintenance line, and the handler skill restricts work to the supplied main-based worktree, so the group is reported not ready rather than claiming completion.",
"reproduction": {
"method": "Local single-node mo-service built from this worktree (make build; select version() = 8.0.30-MatrixOne-v298866877350) launched from /tmp/mo-29886-v2/launch.toml on a fresh DISK-V2 store, frontend 127.0.0.1:6002, with log/tn/cn ports shifted off a sibling worktree's service sharing this machine; ad-hoc SQL via /opt/homebrew/opt/mysql-client/bin/mysql -u root -p111, BVT via the scratch mo-tester runner /tmp/mo-tester-29886b (mo-tester repo untouched) with the CI flags -n -g -o from optools/run_bvt_group.sh; UTs via ./.agents/skills/mo-dev/scripts/mo-cgo-test. Service logs, BVT logs and per-suite report copies are under /tmp/mo-29886-v2/.",
"steps": [
"Run the issue's script verbatim (/tmp/mo-29886/repro.sql): create docs, branch docs_dev, insert (9,9), unqualified delete from docs, data branch merge docs_dev into docs, select; plus the delete-where-id>0 control on d2.",
"Run the residual-main reclaim path (/tmp/mo-29886/probe8.sql): rebuild t via unqualified DELETE, delete the only branch to trigger reclaim, dump mo_branch_metadata/rel_logical_id, then merge an unrelated branch into t.",
"UTs: mo-cgo-test -count=1 ./pkg/frontend/databranchutils/; -run 'TestDataBranchLineageTableIDResolution|TestDataBranchRebuildLineageMissingErrorIsOperationNeutral|TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback' ./pkg/frontend/ (verbose to confirm every new subtest executes); -run 'Branch|Lineage|Subtree|Clone|Snapshot|Reclaim' ./pkg/frontend/.",
"Negative control for finding 1: temporarily restore the rejected subtree-only condition in dataBranchLineageTableID, rerun the two new tests (expected failures), then restore the fix and rerun (pass).",
"BVT with CI flags: -i branch_merge_target_rebuild; -i git4data/branch/metadata; -i git4data/branch; -i git4data/clone."
],
"baseline": "Three baselines. (1) Reporter's v4.2.5 image: the literal script fails with ERROR 20101 'legacy ALTER' because 4.2-dev's TruncateTable path (pkg/sql/compile/ddl.go) still rebuilds with LogicalId preserved and no successor edge - established by the review's cached-branch inspection and the prior round's analysis; not buildable from this worktree. (2) Main-residual path on the unpatched build of this worktree (prior round, change stashed): probe8's post-reclaim merge failed with the exact reported error and the new BVT scored 104/110 with that message at rows 191-193 and 261-263. (3) This round's finding-1 baseline: with the rejected patch's subtree-only discriminator temporarily restored, 'old-version rebuild beside a live sibling branch' fails (endpoint resolved as physical id 20, want flagged lineage id 10) and 'live sibling keeps the component owned' fails with 'An error is expected but got nil' - the silent no-common-ancestor merge the reviewer's counterexample predicted; both pass again after the fix is restored.",
"expected": "The reporter's exact scenario merges to exactly row (9,9) with docs_dev unchanged; a rebuilt target whose lineage descendants were all reclaimed behaves as an ordinary table and merges an unrelated branch to exactly (3,3),(4,4); an old-version rebuild state whose component still has a live logical branch is rejected with an error that says the table was rebuilt and names the endpoint, never mentioning ALTER; genuinely missing lineage is never silently merged as unrelated.",
"observed": "Patched build: repro.sql returns exactly (9,9) for docs after the merge in both the reported case and the predicate control, docs empty before the merge, docs_dev unchanged at (1,1),(2,2),(9,9), and the catalogue shows the live successor edge (level 'alter', p_table_id=old gen). probe8 leaves only the retired branch row after reclaim and the unrelated-branch merge yields exactly (3,3),(4,4). UTs: all focused and owning selections pass, including the new counterexample cases (verbose run listed all subtests). Negative control reproduced the two predicted failures on pre-fix code. BVT: branch_merge_target_rebuild 110/110 (100%); git4data/branch/metadata 310/310; git4data/branch TOTAL 6233, SUCCESS 6213, FAILED 0, IGNORED 20 (the pre-existing @bvt:issue#24840 blocks), ABNORMAL 0; git4data/clone 2501/2501, FAILED 0."
},
"root_cause": "The reported symptom has two layers. (1) On the reporter's v4.2.5 line, a predicate-free DELETE is rewritten into Scope.TruncateTable, a copy-and-swap rebuild that replaces rel_id while preserving rel_logical_id but publishes no successor edge in mo_branch_metadata; dataBranchLineageTableID then saw the physical id absent from the DAG with the LogicalId present and decideLCABranchTSFromBranchDAG rejected DIFF/MERGE with the ALTER-specific message. Current main already publishes the successor edge plus protection snapshot via #28148, so the literal script passes there. (2) The defect still live on main was the discriminator: constructBranchDAGWithLock reads every metadata row without filtering table_deleted, so after DATA BRANCH DELETE reclaims the last live descendant the replaced generation stays a DAG node through the retired branch row while the rebuilt physical id is absent, and the old 'LogicalId in DAG' rule produced the same misleading error for an ordinary table. The first patch fixed that with a subtree-liveness test, and the review then correctly identified its residual gap, now confirmed in code: SubtreeHasLiveNode(LogicalId) is false for an old-version rebuild that retired the branch row without publishing the successor edge while a sibling branch keeps the component alive, because subtree liveness never crosses the shared ancestor; the endpoint then resolved as an unrelated table and decideLCABranchTSFromBranchDAG silently applied no-common-ancestor merge semantics. The correct discriminator is the ownership rule of the reclaim lifecycle itself: alter-lineage compaction retains every row of a connected component that still has a live logical branch (branch_protect_snapshot.go connectedComponent/ComponentHasLiveLogicalBranch), so only a component with no live logical branch anywhere - and no live descendant in the subtree - is legitimately detached; anything else means the missing successor edge is genuine lineage loss that must be rejected. Additionally, the first patch dropped the level column when projecting the metadata read, which would have made every live row (including plain 'alter' pins) look like a logical branch owner to that component test; the level string is now preserved.",
"changes": [
"pkg/frontend/data_branch.go dataBranchLineageTableID: an endpoint whose current physical generation is absent from the lineage while its LogicalId is a node is now flagged only when live lineage still owns the retained rows - lineage.SubtreeHasLiveNode(LogicalId) or the new lineage.ComponentHasLiveLogicalBranch(LogicalId); a fully reclaimed generation group resolves by its own physical id. Comment documents the old-version sibling-branch case and the compaction ownership rule.",
"pkg/frontend/data_branch.go constructBranchDAGWithLock: the mo_branch_metadata row mapping now carries the level string into DataBranchMetadata.Level (in addition to the derived LineageOnly) so the reclaim projection's isLogicalBranchOwnerLevel test sees the real level instead of treating every live row as a logical branch.",
"pkg/frontend/databranchutils/branch_dag.go: BranchLineage.ComponentHasLiveLogicalBranch delegates to the existing BranchReclaimDag.ComponentHasLiveLogicalBranch, keeping the LCA DAG and both liveness projections derived from one catalogue read with no new scan.",
"pkg/frontend/data_branch.go decideLCABranchTSFromBranchDAG + dataBranchRebuildLineageMissingError + constructBranchDAG/ForUpdate returning BranchLineage, and pkg/frontend/clone.go revalidation closure using lineage.DAG: carried over from the prior round (operation-neutral diagnostic naming every affected endpoint; single-read projection; behavior-preserving clone adaptation).",
"pkg/frontend/data_branch_hashdiff_test.go: TestDataBranchLineageTableIDResolution gains 'old-version rebuild beside a live sibling branch' (flagged), 'whole component reclaimed including siblings' (resolves by physical id), and 'historical pin without a live logical branch' (live plain-alter row does not own the component), with explicit level strings on all fixture rows; new newMrsForBranchMetadataDAG helper builds the branchDAGSelectSQL-shaped result set; new TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback drives decideLCABranchTSFromBranchDAG through a mocked BackgroundExec and asserts the sibling-alive state returns exactly dataBranchRebuildLineageMissingError("db1.docs") with lcaTableId 0, while the fully retired state returns nil error with the synthetic single-node path [20].",
"pkg/frontend/databranchutils/branch_dag_test.go TestBranchLineageProjectsOneRead: extended with component-projection assertions for the retired-child-with-live-sibling case, the whole-component-retired case, the plain-alter historical-pin split, and the empty lineage.",
"test/distributed/cases/git4data/branch/metadata/branch_merge_target_rebuild.sql and .result: unchanged this round (110 statements; issue repro with catalogue assertions, both controls, repeated rebuilds, single- and two-generation reclaim counterexamples, same-name DROP/CREATE counterexample) and re-verified against the revised build."
],
"tests": [
"make build -> exit 0 (mo-service relinked, version 8.0.30-MatrixOne-v298866877350); gofmt -l on all five touched Go files -> clean.",
"./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/frontend/databranchutils/ -> ok 3.177s (whole package, including the extended TestBranchLineageProjectsOneRead).",
"./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run 'TestDataBranchLineageTableIDResolution|TestDataBranchRebuildLineageMissingErrorIsOperationNeutral|TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback' ./pkg/frontend/ -> ok 3.176s; verbose rerun listed all nine resolution subtests and both decideLCA subtests as PASS.",
"./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run 'Branch|Lineage|Subtree|Clone|Snapshot|Reclaim' ./pkg/frontend/ -> ok 2.807s.",
"Negative control (finding 1): with the subtree-only condition temporarily restored, TestDataBranchLineageTableIDResolution/old-version_rebuild_beside_a_live_sibling_branch FAILS (expected lineage id 0xa, actual 0x14) and TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback/live_sibling_keeps_the_component_owned FAILS ('An error is expected but got nil'); fix restored, both pass.",
"Ad-hoc SQL on the patched build: /tmp/mo-29886/repro.sql -> docs exactly (9,9) after the merge in both the reported case and the predicate control, docs_dev unchanged; /tmp/mo-29886/probe8.sql -> after DATA BRANCH DELETE reclaim only the retired branch row remains (alter edge gone) and merging the unrelated branch yields exactly (3,3),(4,4).",
"BVT (scratch runner, CI flags -n -g -o): -i branch_merge_target_rebuild -> TOTAL 110, SUCCESS 110, FAILED 0, 100%.",
"BVT: -i git4data/branch/metadata -> TOTAL 310, SUCCESS 310, FAILED 0, 100%.",
"BVT: -i git4data/branch -> TOTAL 6233, SUCCESS 6213, FAILED 0, IGNORED 20, ABNORMAL 0, 100% (includes branch_rebuild_lifecycle and every diff/merge/pick/protect/privilege case); an earlier attempt of this suite was invalidated when an external SIGTERM killed the service mid-run (its 5095 ABNORMAL statements were connection losses, FAILED 0) and was rerun to completion after relaunching the service detached.",
"BVT: -i git4data/clone -> TOTAL 2501, SUCCESS 2501, FAILED 0, 100% (covers the clone.go call site); error.txt empty for all passing runs."
],
"proof": [
"Reviewer counterexample closed at three levels: the pure projection (SubtreeHasLiveNode(10)=false while ComponentHasLiveLogicalBranch(10)=true beside a live sibling), the endpoint resolver (lineage id 10 + qualified name 'db1.docs' returned), and decideLCABranchTSFromBranchDAG through a mocked metadata read (exact dataBranchRebuildLineageMissingError text, lcaTableId 0) - DIFF/MERGE rejects the missing ancestry instead of converting it into a no-common-ancestor merge.",
"The negative control proves these tests detect the rejected patch's defect: on subtree-only code the sibling-alive endpoint resolved as physical id 20 and decideLCA returned nil, which was the silent wrong merge; the restored component rule rejects it.",
"The legitimate reclaim family still passes: 'whole component reclaimed including siblings' resolves by physical id at UT level, and the BVT's single-generation and two-generation reclaim sections still DIFF/MERGE to exactly (3,3),(4,4) after reclaim, so distinguishing genuine loss did not reintroduce the original false positive.",
"The rule matches the compaction ownership split, not mere row presence: 'historical pin without a live logical branch' (live plain-alter row, all logical branches retired) still resolves by physical id, pinned by UT on both projections.",
"The level-string preservation is load-bearing and covered: the ownership test reads DataBranchMetadata.Level, and the fixtures use real levels ('table', 'alter'), so a regression that drops the level again would flip the component verdicts in TestBranchLineageProjectsOneRead.",
"No regression on owning surfaces: full git4data/branch (6233 statements), git4data/branch/metadata (310), git4data/clone (2501) and the new 110-statement case all pass with CI flags; focused and broader frontend/databranchutils UT selections pass; make build and gofmt clean.",
"Reporter's exact script on the patched build yields exactly (9,9) with docs_dev unchanged, and the predicate control is identical, which is the issue's stated expected behavior for the merge semantics this worktree can deliver."
],
"risks": [
"Scope boundary (review finding 2): the reporter's v4.2.5 image is fixed only by backporting the #28148 rebuild-lineage publication protocol to the 4.2 maintenance line; this loop supplied a main-based worktree and the handler skill restricts work to it, so that backport is not delivered here and the issue group must not be marked complete on this change alone.",
"The skill's deferred path asks for an issue comment and replacing severity/s0 with deferred; no GitHub tools are available in this session (MCP search returned none), so neither action was performed - the controller or a later turn must do it.",
"The reworded diagnostic's fire path is not reachable through ordinary SQL on patched main (a successor edge is always published while a live descendant exists, and old-version metadata cannot be created by SQL on this build), so it is proven by the mocked decideLCABranchTS regression rather than a BVT error assertion.",
"The worktree HEAD is 38 commits behind origin/main and fast-forwardable; the rebase belongs to the PR-creation turn. No commit, push, branch, or PR was created and nothing was staged.",
"Verification environment notes: a sibling worktree's mo-service shares this machine (ports were shifted; logs under /tmp/mo-29886-v2), one earlier suite attempt was invalidated by an external SIGTERM and rerun cleanly, and the scratch service was shut down (graceful 'Shutdown complete') after verification; restart with ./mo-service -launch /tmp/mo-29886-v2/launch.toml (~30s on the bootstrapped store; dump user already created).",
"Extra cost is one O(rows) component walk per DIFF/MERGE endpoint whose current generation is absent from the lineage (the already-fetched rows); no additional catalogue read, lock, or transaction was added."
],
"deferred_reason": "The remaining blocker is out of this worktree's reach, not unproven: issue #29886 is reported against v4.2.5, whose TruncateTable rebuild still drops and recreates the physical table without publishing the successor generation edge (cached origin/4.2-dev pkg/sql/compile/ddl.go), so the reporter's exact failure persists there until the #28148 rebuild-lineage protocol (edge publication, postponed replacement-DROP reclaim, protection snapshot, shared retire/reclaim helper, with the maintenance branch's existing ALTER lineage helpers and current lifecycle corrections) is adapted to the 4.2 maintenance line and proven with the original reproduction failing before and returning exactly (9,9) after. The handler skill confines work to the supplied worktree, which is main-based (02a2823), and main already contains that protocol, so the backport cannot be produced or tested from here without creating a new worktree, which this loop forbids. The main-side deliverable in this worktree is complete and re-verified after fixing review finding 1 (component-ownership discriminator, level preservation, counterexample and decideLCA regressions, 110/110 new BVT, 6233-statement branch suite, 2501-statement clone suite, owning UTs, negative control) and can be shipped as a separate main PR, but per the reviewer it does not close the reported environment. Next human action: supply a 4.2-dev-based worktree/job for the backport (or accept the main-only residual fix as a separate PR explicitly not closing this issue), and post the deferral analysis plus the severity/s0 -> deferred label change on the issue, which this session could not do for lack of GitHub tools.",
"issue_reports": [
{
"number": 29886,
"reproduction": {
"method": "Local single-node mo-service built from this worktree (make build; version 8.0.30-MatrixOne-v298866877350) on /tmp/mo-29886-v2/launch.toml, frontend 127.0.0.1:6002 on a fresh DISK-V2 store; SQL via mysql client, BVT via scratch mo-tester /tmp/mo-tester-29886b with CI flags -n -g -o; UTs via ./.agents/skills/mo-dev/scripts/mo-cgo-test.",
"steps": [
"Issue script verbatim (/tmp/mo-29886/repro.sql): unqualified DELETE on the merge target then DATA BRANCH MERGE, select id,v; plus the delete-where-id>0 control.",
"Residual-main reclaim path (/tmp/mo-29886/probe8.sql): rebuild t, delete its only branch (reclaim), then merge an unrelated branch into t.",
"UT matrix incl. the review counterexample (rows {10->1 deleted, 11->1 live}, endpoint physical 20 / LogicalId 10) and the fully-reclaimed variant.",
"Negative control: temporarily restore the subtree-only discriminator, rerun the new tests, restore the fix.",
"BVT: -i branch_merge_target_rebuild; -i git4data/branch/metadata; -i git4data/branch; -i git4data/clone."
],
"baseline": "Reporter's v4.2.5 image fails the literal script with ERROR 20101 'legacy ALTER' (4.2-dev publishes no successor edge; established by cached-branch inspection, not buildable from this worktree). Unpatched main of this worktree passes the literal script (#28148 present) but fails the post-reclaim path with the same reported error (probe8, prior round; BVT 104/110 at rows 191-193/261-263). Rejected-patch baseline this round: the sibling-alive old-version state resolves as an unrelated table and decideLCA returns nil instead of the rejection - the review's finding 1, reproduced by the negative control.",
"expected": "Merge succeeds with exactly (9,9) and the branch unchanged; reclaimed-generation targets behave as ordinary tables merging an unrelated branch to exactly (3,3),(4,4); genuine lineage loss (live descendant, or live logical branch anywhere in the component) is rejected with an operation-neutral rebuilt-table diagnostic naming the endpoint; predicate and rewrite-disabled DELETE controls behave identically to the unqualified case.",
"observed": "All observed on the patched build: repro returns exactly (9,9) both cases with docs_dev unchanged and a live level-'alter' successor edge in the catalogue; probe8's post-reclaim merge returns exactly (3,3),(4,4) with only the retired branch row remaining; the sibling-alive UT cases flag the endpoint and decideLCA returns exactly the operation-neutral error; the fully-reclaimed cases resolve by physical id with no-LCA semantics; BVT 110/110, 310/310, 6213/6233 (0 failed, 20 pre-existing ignored), 2501/2501; owning UTs pass; negative control confirms the new tests fail on the pre-fix discriminator."
},
"root_cause": "Predicate-free DELETE is rewritten into Scope.TruncateTable, a copy-and-swap rebuild that replaces rel_id while preserving rel_logical_id. On 4.2 no successor edge is published, so dataBranchLineageTableID saw the physical id absent with the LogicalId present and rejected DIFF/MERGE with the ALTER-specific message. Main already publishes the edge via #28148; its residual defect was the discriminator itself, which treated any retired-row-backed DAG membership as lineage loss after reclaim. The rejected fix's subtree-liveness test then under-rejected: an old-version rebuild that retires the branch row without a successor edge while a sibling branch keeps the connected component alive has a dead subtree, so the endpoint resolved as an unrelated table and merged with no common ancestor. The correct rule is the reclaim lifecycle's own ownership semantics: only a connected component with no live logical branch anywhere (and no live subtree descendant) is legitimately detached; otherwise the missing successor edge is genuine lineage loss that must be rejected, and the level string must survive the metadata projection for that ownership test to be faithful.",
"changes": [
"dataBranchLineageTableID flags an endpoint only when SubtreeHasLiveNode(LogicalId) or ComponentHasLiveLogicalBranch(LogicalId) - the compaction ownership rule - so fully reclaimed groups resolve by physical id and sibling-alive old-version states are rejected.",
"constructBranchDAGWithLock preserves the level string into DataBranchMetadata.Level for the reclaim projection.",
"BranchLineage.ComponentHasLiveLogicalBranch added, delegating to the existing BranchReclaimDag rule with no second catalogue scan.",
"Prior-round changes retained: operation-neutral dataBranchRebuildLineageMissingError naming every endpoint, BranchLineage single-read projection through constructBranchDAG/ForUpdate and clone.go, 110-statement BVT pair.",
"Tests: counterexample, whole-component-reclaimed, and historical-pin resolution cases; decideLCABranchTSFromBranchDAG regression with mocked metadata (rejection precedes the no-LCA fallback; fully retired state keeps no-LCA semantics); component-projection assertions in TestBranchLineageProjectsOneRead."
],
"tests": [
"mo-cgo-test -count=1 ./pkg/frontend/databranchutils/ -> ok 3.177s.",
"mo-cgo-test -count=1 -run 'TestDataBranchLineageTableIDResolution|TestDataBranchRebuildLineageMissingErrorIsOperationNeutral|TestDecideLCABranchTSRejectsOldVersionRebuildWithoutNoLCAFallback' ./pkg/frontend/ -> ok (verbose: all subtests PASS).",
"mo-cgo-test -count=1 -run 'Branch|Lineage|Subtree|Clone|Snapshot|Reclaim' ./pkg/frontend/ -> ok 2.807s.",
"Negative control: two new tests fail on the temporarily restored subtree-only discriminator, pass after the fix.",
"make build exit 0; gofmt clean on all five touched files.",
"BVT CI flags: branch_merge_target_rebuild 110/110; git4data/branch/metadata 310/310; git4data/branch 6213/6233 SUCCESS with 0 FAILED/20 IGNORED/0 ABNORMAL; git4data/clone 2501/2501.",
"Ad-hoc: repro.sql -> exactly (9,9) both cases; probe8.sql -> post-reclaim merge exactly (3,3),(4,4)."
],
"proof": [
"The reviewer's counterexample is now rejected at projection, resolver, and decideLCABranchTS levels, with the exact operation-neutral error text asserted, and the negative control proves these tests catch the previous defect.",
"Legitimate reclaim still passes: UT whole-component case and the BVT single-/two-generation reclaim sections (exactly (3,3),(4,4)), so the false-positive fix is preserved.",
"The compaction ownership split is pinned: a live plain-alter historical pin does not own the component, matching ComputeAlterLineageCompactionPlan's live-logical-branch rule.",
"Reporter's script yields exactly (9,9) with the branch unchanged on the patched build; controls identical.",
"No owning-surface regression: 6233-statement branch suite, 310-statement metadata suite, 2501-statement clone suite, and all focused UT selections pass with CI flags; the reporter's v4.2.5 environment itself remains unfixed pending the 4.2 backport, which this main-based worktree cannot produce."
]
}
]
}
Please use this analysis to provide the missing decision, environment, evidence, or ownership
needed before the issue is returned to the AI candidate pool.
MatrixAdventurer commentedon Oct 14, 2026
收到并认可该 triage 结论(由LW授权的MOI智能体提交):
MatrixAdventurer commentedon Oct 22, 2026
main already contains the fix via #28148; whether to backport it to v4.2.5 is up to the release owners. Closing as completed on main.