Repository navigation
fix: preserve Data Branch lineage across TRUNCATE - #28148
Conversation
a188fbf to
13d78e3
Compare
|
Mergify auto-update failure triage: this was infrastructure, not a MatrixOne code or test failure. The failed check reports: |
27487af to
d1e07e6
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact HEAD 5c9c375. No blocking findings.
The change keeps the physical replacement, successor lineage edge, protection snapshot, old-generation retirement, and compaction in one statement transaction. skipDataBranchReclaim is scoped only to the internal replacement DROP and is reset on Compile reuse; every subsequent failure rolls back the CREATE/metadata transition rather than exposing a detached table. The live relation ID is re-resolved after the RC snapshot barrier, closing stale-plan and concurrent replacement cases.
I traced the lifecycle counterexamples: consecutive TRUNCATE / predicate-free DELETE, explicit-transaction rejection, historical-only owners, branch deletion, and concurrent owner mutation. Pessimistic execution is serialized by the source metadata and lifecycle locks (deadlocks resolve through statement retry); optimistic execution conflicts on the lifecycle write. Snapshot/metadata growth remains tied to the existing ALTER lineage contract and is reclaimed when the logical/historical owner terminates. The new BVT checks physical-ID replacement, active/retired rows, protection snapshots, DIFF, DELETE cleanup, predicate DELETE control, and rejection atomicity; exact-head author evidence covers compile/engine packages and the public SQL path.
5c9c375 to
4b85530
Compare
|
@Mergifyio queue |
Merge Queue Status
This pull request spent 37 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
4b85530 to
f6cefa0
Compare
|
@Mergifyio queue |
☑️ Command
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed the full exact-head diff at 6c5258dacd3a6af5fc9148e3f55c515e3e3a0b9b, including the production lineage protocol and the new explicit-transaction regression test. I found no correctness, performance, or unhappy-path blocker.
The TRUNCATE path now treats replacement as one atomic copy/swap lineage transition: resolve and lock the old physical generation, take the RC freshness barrier where required, acquire the owner-lifecycle barrier, preserve the old edge through the internal DROP, create the successor, publish the successor edge, then run the same reclaim/compaction transition as ordinary DROP. Failures before commit roll the entire DDL transaction back. The skip-reclaim option is statement-local, passed only to this internal DROP, and reset when Compile is reused.
Counterexamples checked: consecutive TRUNCATE generations, delete-as-truncate, historical snapshot/PITR ownership, live logical branches, relation replacement while waiting for an RC lock, explicit transactions, branch deletion/reclaim, and failures between DROP/CREATE/publication/reclaim. The latest test-only commit closes the exact TRUNCATE explicit-transaction gate without changing runtime behavior.
Resource/liveness audit: Q1 — lineage metadata, source snapshots, and replacement IDs remain transaction-owned and reclaim is shared with DROP; Q2 — no goroutine/channel/wait lifecycle is introduced, and all error exits are transaction rollback paths; Q3 — work is bounded by the existing lineage DAG/history probes, with no retry loop or unbounded allocation added. Ordinary TRUNCATE does pay the existing lineage serialization/probe cost required to exclude concurrent owner publication, but adds no row-data scan.
CI is still running on this exact head; per request I did not wait for it.
|
Unrelated CI blocker:
Resolved since this comment: #28171 is closed, and its sampled- |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #26064
What this PR does / why we need it:
Root cause:
Scope.TruncateTabledrops the old physical relation before the replacement ID exists. The normal DROP hook therefore retires the active Data Branch row and reclaims its protection snapshot; the replacement has no lineage metadata.DELETE FROM twithout a predicate uses this same path.Changes:
alter:tableedge and protection snapshot, then invoke the same shared reclaim-and-compaction lifecycle used by ordinary DROP.DATA BRANCH DIFF,DATA BRANCH DELETE, predicate DELETE, and explicit-transaction atomicity.TestCCPRGC's intentionally minimal system catalog with the snapshots, PITR, and branch-metadata tables now read by its predicate-free DELETE/TRUNCATE path. Missing production catalog tables still surface as errors; this fixture now matches bootstrap.Issue-to-test proof:
test/distributed/cases/git4data/branch/metadata/branch_rebuild_lifecycle.sqlproves every reported rebuild form obtains a new physical ID while retaining a live lineage edge and all required protection snapshots. It also proves DIFF and DELETE succeed, and that DELETE reclaims the full generation chain.TestCCPRGCexercises its five CCPR GC states through predicate-free DELETE after initializing every required system catalog dependency.Tests run:
make build./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=15m ./pkg/sql/compile./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/util/executor./run.sh -p test/distributed/cases/git4data/branch/metadata -m genrs -i branch_rebuild_lifecyclewith mo-tester (generated result inspected)./run.sh -p test/distributed/cases/git4data/branch/metadata -m run -i branch_rebuild_lifecyclewith mo-tester — 59/59 passedRebase verification on
494e6a7723: thepkg/sql/compileandpkg/util/executorCGo suites passed again; BVTbranch_rebuild_lifecyclepassed again, 59/59../.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m -run '^TestCCPRGC$' ./pkg/vm/engine/test— passed../.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=15m ./pkg/vm/engine/test— passed in 146.851s../.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m ./pkg/sql/compile— passed.Rebase verification on
149219181f:pkg/sql/compileCGo suite passed in 6.080s;TestCCPRGCpassed in 4.079s.Rebase verification on
8a83e3e31e:make buildpassed;pkg/sql/compileCGo suite passed in 9.548s;TestCCPRGCpassed in 4.120s;branch_rebuild_lifecycleBVT passed 59/59 in normal comparison mode on a clean single-node instance. Report and error report were inspected.Rebase verification on
e6b25ee772: controlled CGopkg/sql/compilepassed in 6.702s andTestCCPRGCpassed in 4.473s. The upstream change is limited to window-frame binding and its tests, with no Data Branch/DDL overlap; the prior clean-instance lifecycle BVT evidence remains applicable.Rebase verification on
0fdc39e236: controlled CGopkg/sql/compilepassed in 8.040s andTestCCPRGCpassed in 4.153s. Upstream touched GROUP spill performance, BOOL aggregate compatibility, and unrelated BVT expectations, with no Data Branch/DDL lifecycle overlap; the prior clean-instance lifecycle BVT evidence remains applicable.Rebase verification on
243b77a742: controlled CGopkg/sql/compilepassed in 7.235s andTestCCPRGCpassed in 5.575s. Upstream changed cluster-table INSERT planning only, with no Data Branch/DDL lifecycle overlap; the prior clean-instance lifecycle BVT evidence remains applicable.Rebase verification on
4356759714: controlled CGopkg/sql/compilepassed in 7.315s andTestCCPRGCpassed in 5.173s. Upstream added bounded exact DISTINCT spill support and a portable SCA-cache workflow tweak, with no Data Branch/DDL lifecycle overlap; the prior clean-instance lifecycle BVT evidence remains applicable.Rebase verification on
425da14974:make buildpassed; controlled CGopkg/sql/compilepassed in 8.041s;TestCCPRGCpassed in 4.002s; and the clean-single-nodebranch_rebuild_lifecycleBVT passed 59/59 in normal comparison mode. The report and error report were inspected. Upstream changed float table-lock keyspace coverage, adjacent to the lock boundary, so this public regression was rerun.Rebase verification on
922e792ebf:make buildpassed; controlled CGopkg/sql/compilepassed in 6.080s;TestCCPRGCpassed in 5.327s; and the clean-single-nodebranch_rebuild_lifecycleBVT passed 59/59 in normal comparison mode. The report and error report were inspected. Upstream changes lock-owner recovery, a lifecycle concurrency dependency, so this public regression was rerun.Coverage follow-up after the 73.91% changed-code CI result: added
TestPrepareAlterDataBranchLineageRejectsLiveBranchTxnWithStatement, which reaches active-lineage DAG admission and proves the exactTRUNCATEexplicit-transaction rejection before compaction or replacement. The focused controlled-CGo suite passed in 2.432s and the owningpkg/sql/compilepackage passed in 6.208s.Rebase verification on
26d008dbd0: the two upstream commits modify aggregate recovery and grant-test cleanup only; they do not touch Data Branch or lifecycle dependencies. The public lifecycle BVT evidence from the prior exact production revision remains valid.Rebase verification on
fa829e5c50:make buildpassed; the focused controlled-CGo lifecycle suite passed in 1.320s; the owningpkg/sql/compilepackage passed in 6.886s; and the clean-single-nodebranch_rebuild_lifecycleBVT passed 59/59 with an empty error report. Upstream exposes subscription tables and hardens HAKeeper replica removal; the former is adjacent to clone behavior, so the public Data Branch regression was rerun.Rebase verification on
2bf4dddb3c:make buildpassed; focused controlled-CGo lineage and Data Branch projection suites passed in 1.306s and 1.416s; owningpkg/sql/compileandpkg/frontendpackages passed in 7.593s and 18.644s; the race-enabledpkg/sql/compilepackage passed in 9.129s. On a clean ready single-node service, upstreamdiff_composite_pk_columnspassed 28/28 twice andbranch_rebuild_lifecyclepassed 59/59 twice; every error report was empty and the service log emitted no fatal or panic record. The upstream primary-key projection change is a direct DIFF consumer, so both public paths were rerun.Rebase verification on
522285b47a: on the preceding3facd79c8arebase,make buildpassed; the combined upstream hash-partition and lineage gate suite passed in 2.490s; full and race-enabledpkg/sql/compilepassed in 6.350s and 8.477s. On the exact final head, the lineage gate passed in 1.325s and the upstream owningpkg/sql/colexec/aggexecandpkg/sql/colexec/windowpackages passed in 23.401s and 1.233s. The first upstream commit changed compiler hash-partition protocol gating; the second is confined to bounded-RANGE aggregate/window execution. Neither alters Data Branch DDL lifecycle state. A concurrent issue [Performance]: REPLACE INTO conflict detection falls back to loop join on large tables #27141 run owned the shared mo-testerrun.ymland reports, so its cleanup failed before this BVT executed; no new BVT pass/fail status is claimed. The direct clean-instance lifecycle BVT evidence remains documented above.Rebase verification on
d300619bb4: the sampled-statistics and Iceberg manifest-bound commits do not change the Data Branch TRUNCATE protocol or its compiler/executor/test/BVT files. On exact heade9498ef2a3, controlled CGo lineage admission tests passed in 1.413s andTestCCPRGCpassed in 4.111s, covering the explicit-transaction gate and predicate-free DELETE cleanup consumer. Prior full compiler/race and clean-instance lifecycle BVT evidence remains semantically valid.Residual risks:
Rebase verification
Rebased onto
e74cdbe5df, including313991b503(PR #28172), which corrects the sampledANALYZEexpectation behind the previously unrelatedwindow_hash_partitionBVT failure. The Data Branch lineage diff is unchanged by the rebase. Focused CGo validation passed for the compile lineage gates andpkg/vm/engine/testCCPR GC coverage.