Repository navigation
fix(frontend): order composite lineage lifecycle locks - #28325
Conversation
5259954 to
e63439a
Compare
e63439a to
4177b2b
Compare
4177b2b to
4acf574
Compare
9abab31 to
2d82020
Compare
2d82020 to
c7c66bb
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed for d71f4db against 0b195e4. No blocking issue found.
Read all six changed files and traced public/nested CLONE and DIFF/PICK/MERGE admission, background/shared transaction ownership, target-lock retry, and final commit/rollback. This is a lock-order bug fix reusing existing catalog gates, not a new persistent/protocol design.
The leading lineage gate is taken before endpoint/catalog resolution in owned transactions. A replacement transaction reacquires it before retrying the target key; the retry remains bounded to one and excludes shared/data-branch-owned transactions. Admission errors finish/close the owned executor; explicit CLONE preserves its original transaction authority, while explicit DATA BRANCH retains commit-time validation.
| Audit closure | Result |
|---|---|
| Q1 executor/transaction ownership | Factory failure closes locally; admission failure invokes finalizer; success transfers one finalizer to caller. |
| Q2 lock order / retry | Owned composite work follows lineage -> view/catalog/object; retry re-enters the leading gate. Shared transactions are not rolled back by the new retry helper. |
| Q3 retained work | No new queue/cache/background worker; one bounded retry. Tests have bounded contexts and operation joins. |
The tests retain result/uniqueness/commit-order assertions while changing the #27040 waiter observation to the new leading gate. The new real two-CN scenarios exercise clone/view/fulltext, DIFF, and destination conflicts for PICK/MERGE against unrelated DROP. Reused the author's current-base normal tests, semantically current race/topology evidence, full-package runs and exact 20-round external workload rather than claiming a new run. The documented JDBC metadata-only limitation is not represented as a strict BVT pass.
The broader serialization at the existing global gate is an explicit correctness tradeoff, supported by the concurrent workload evidence; it is not a claim of unchanged peak clone throughput. A future finer-grained optimization should preserve the same lock-order proof. Approval is for this exact head.
Merge Queue Status
This pull request spent 15 seconds in the queue, including 1 second running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
Related to #26404
What this PR does / why we need it:
Root cause
Mixed DATA BRANCH and CLONE workflows used inconsistent lock order. DIFF, PICK, MERGE, and ordinary CLONE could first acquire catalog/view/object locks and only later enter nested scratch/restore/drop paths that acquire the existing lineage-owner lifecycle row lock. Concurrent DROP, SNAPSHOT, and branch operations acquire the lineage lock first and then catalog/view/object locks. Across CNs these two orders can form a distributed wait cycle even when the business database names are independent.
The previous revision of this PR tried to merge the view and lineage gates. That changed the restore catalog contract and caused both unit and broad BVT regressions when
mo_feature_registrywas unavailable in tenant/PITR restore contexts. This revision restores the two existing gates and corrects only composite-operation admission order.Changes
IF NOT EXISTSclone regression to observe the new leading lineage lifecycle gate while preserving its transaction-order and result assertions.Issue-to-test proof
TestIssue26404MixedDataBranchLifecycleDoesNotDeadlockruns authenticated SQL through a real two-CN cluster. It uses lock-service waiter barriers rather than timing sleeps and covers:The exact external regression set from #26404 was also run for 20 rounds at concurrency 9: 200/200 cases and 4,840/4,840 statements passed, with no deadlock or
20701in runner/server logs.Validation
main@0b195e4f5a;git range-diffconfirms both issue commits are unchangedTestIssue26404MixedDataBranchLifecycleDoesNotDeadlock:-count=3TestIssue26404MixedDataBranchLifecycleDoesNotDeadlock:-race -count=1TestIssue27040ConcurrentIfNotExistsDatabaseClone:-count=3TestIssue27040ConcurrentIfNotExistsDatabaseClone: focused frontend coverage mode and-race -count=1./pkg/catalog ./pkg/frontend/databranchutils ./pkg/sql/compile ./pkg/frontendafter the shared SNAPSHOT/View-gate change landed./pkg/frontend./pkg/tests/issuesTestIssue26087ConcurrentDataBranchQuota,TestIssue26640AccountPITRUsesCatalogRestoreHandlers, andTestIssue28317ViewSnapshotGateOrderSQLgo vet ./pkg/frontend ./pkg/tests/issueswith the repository CGo environmentmake build--repeat 20 -j 9temporary_table_cloneBVT after the temporary-DDL transaction change: 166/166 statements passed with JDBC metadata ignoredgit diff --checkAfter upstream #28322 unified SNAPSHOT -> View locking, the shared lock packages, frontend/compile packages, the real two-CN issue test, all three adjacent regressions, and the race case were rerun successfully. After upstream #28332 made temporary DDL transaction-independent, focused/full frontend and compile tests, the real two-CN issue test,
make build, and the existing 166-statement temporary-clone BVT were rerun. The local machine has JDK 17 rather than the tester-required JDK 8: normal BVT comparison reported 12 JDBC display-width-only differences, each inspected against the SQL and expected data/DDL/error semantics;-nthen proved all 166 semantic results. No result file was regenerated or changed.The old-head Ubuntu UT, UT coverage, and pessimistic multi-CN BVT failures in workflow run 34098109436 all traced to the discarded shared-gate revision; local exact regression tests pass with this revision. They are not unrelated CI blockers.
Workflow run 34125753066 exposed one stale assertion in the existing #27040 regression: it still expected the second clone to wait at the target
mo_databasekey, but this PR intentionally admits clone at the lineage lifecycle gate first. Commitd71f4dbdupdates only that observation point; the original early-return, commit-order, uniqueness, and payload assertions remain intact. The same job also reproduced the unrelated #28313 shuffle-pool failure, while its pessimistic BVT job reproduced the then-unresolved #28352 temporary-table ALTER failure; the aggregate Coverage failure was a consequence of those failed producers.After rebasing onto upstream #28343's remote-bind convergence change and #28096's frontend
MEMBER OFsupport, the eight focused frontend admission/retry/error-path tests and the fullpkg/frontendpackage passed. The real two-CN #26404 regression and the adjacent #27040 clone regression each passed three normal runs and one race run, validating the current lockservice dependency rather than reusing the older topology evidence. Main then advanced with #28356's executor-owned temporary ALTER COPY transaction fix, which resolved #28352. A secondrange-diffremained unchanged; the eight focused frontend tests and both two-CN regressions were rerun onmain@fdc1e0ca8f, with three normal runs per regression and a combined race run passing.Pre-rebase workflow run 34150466865 passed Linux UT, coverage UT, SCA, Proxy and pessimistic multi-CN BVT, and aggregate Coverage; the remaining completed jobs were successful, neutral, or intentionally skipped. Main then added only #28355's correlated scalar-aggregate planner optimization. A third
range-diffremained unchanged, and the eight focused frontend tests plus both real two-CN regressions passed onmain@0b195e4f5a; the existing race evidence remains valid because neither the PR's synchronization code nor its lockservice dependency changed.Residual risk
The corrected order intentionally serializes these composite autocommit workflows at the existing global lineage lifecycle boundary for their owned transaction. The 20-round exact workload completed without stalls. Explicit user-transaction behavior is unchanged and is outside the reported autocommit workload.