Repository navigation
fix(frontend): order account lifecycle gates - #28436
mergify[bot] merged 4 commits into
Conversation
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? |
|
Review conclusion at b96d410: no blocking code finding; recommend approval once required CI passes. Read the complete three-file diff against base/merge-base fe802bd and traced #28433 through CREATE, standalone DROP, data-branch target-account admission, View lifecycle locking, and transaction completion. The new gate is acquired inside CREATE’s owned transaction before __mo_account_lock. The later SNAPSHOT -> View order remains intact, and DROP’s owner-publication write barrier is unchanged. ALTER ACCOUNT does not introduce a reverse SNAPSHOT acquisition in the checked transaction path.
Compatibility fallback remains restricted to missing-table/missing-database errors when View metadata refresh is disabled; ordinary lock/transaction errors are not swallowed. The focused UT correctly checks failure-before-account-lock plus rollback. Author reports the focused CGo UT and 13/13 real two-CN CREATE/DROP pairs with zero residue; those are author-run evidence, not tests I independently executed. Diff check passed. Current CI run 34249898003 is still running, so this is not a claim of completed CI or a waiver of its checks. No live environment or heavyweight UT was started during review. Operational caveat: acquiring the existing global SNAPSHOT gate earlier lengthens its hold interval and serializes CREATE initialization with other lifecycle work. That is the explicit lock-order tradeoff here, not a fix for the separate #28079 lifecycle-throughput issue; no throughput improvement is claimed. During a mixed-version rollout, old CNs still retain the old ordering until upgraded. The authenticated account is the PR author; GitHub does not permit a formal self-APPROVE. Recording the recommendation for an independent maintainer. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review at b96d410 against base/merge-base fe802bd: no confirmed blocker. APPROVE.
Reviewed every hunk in authenticate.go, authenticate_test.go and snapshot.go, and traced CREATE, standalone DROP, restore account recreation, data-branch target-account admission (including explicit-transaction fast-fail commit validation), ALTER ACCOUNT, View gate ordering and transaction completion. This is a bounded bug fix to existing locking, so the feature-design artifact gate is not triggered.
The R3 contract is consistent: CREATE takes the sys SNAPSHOT row in its existing transaction before __mo_account_lock, and later retains SNAPSHOT -> View ordering. DROP's owner-publication write barrier is preserved. ALTER does not acquire SNAPSHOT after its account-name lock. The compatibility helper preserves the existing restriction to NoSuchTable/BadDB while View metadata refresh is disabled; other failures propagate. An ignored gate error is overwritten by the subsequent account-lock SQL construction before transaction completion.
| Audit | Result |
|---|---|
| Q1 ownership/error paths | The same background transaction owns both locks through commit/rollback. Gate failure reaches finishTxn before account mutation; commit failure attempts rollback. Account resolution changes do not create another transaction. |
| Q2 ordering/liveness | Removes the account-name -> SNAPSHOT versus SNAPSHOT -> account-name cycle. Existing transaction cancellation/completion remains the release mechanism; no new local mutex, callback, goroutine or cleanup wait. Explicit branch commit admission remains FastFail. |
| Q3 boundedness | One additional existing-row query per CREATE; its result is cleared before account locking. No new retained collection or worker. |
| Compatibility/performance | No schema, protocol, config or generated-artifact change. Earlier global-gate acquisition extends serialization across account initialization; this is the accepted lock-order tradeoff, not a throughput improvement. Old CNs retain old ordering until upgraded. |
Validation reused: exact-head Actions run 34249898003 completed successfully, including Linux UT (log confirms race mode), UT coverage, shared build, SCA and both active multi-CN BVT jobs. The downloaded coverage artifact records execution of the added gate and error-return blocks. The new injected-error UT has a deterministic begin -> gate -> rollback oracle and excludes account locking. The author reports the named focused CGo UT and 13/13 real two-CN CREATE/DROP pairs with zero residue; these are author-run evidence, not independently replayed tests. No changed in-process concurrent test warrants repeated Go race stress for this SQL lock-order fix. Skipped CI jobs are not counted as passes. Exact-range diff check passed.
No code or working-tree files changed during this review.
Merge Queue Status
This pull request spent 51 minutes 44 seconds in the queue, including 51 minutes 16 seconds running CI. Required conditions to merge
|
`CREATE ACCOUNT` acquired the per-account `__mo_account_lock` first and later entered the global `SNAPSHOT` lifecycle gate while revalidating account View metadata. A standalone `DROP ACCOUNT` already enters the `SNAPSHOT` lineage lifecycle barrier before acquiring the same account-name lock. Concurrent CREATE/DROP of one account could therefore form a distributed lock cycle. Take the existing `SNAPSHOT` gate at the beginning of CREATE's owned transaction, before the account-name lock. This preserves DROP's owner publication barrier and aligns CREATE, DROP, and data-branch target-account locking to one order: ``` SNAPSHOT lifecycle gate -> __mo_account_lock ``` The compatibility behavior for deployments where the View metadata catalog is not available is retained: when View metadata refresh is disabled, missing catalog-table errors still bypass the optional gate. Approved by: @XuPeng-SH
`CREATE ACCOUNT` acquired the per-account `__mo_account_lock` first and later entered the global `SNAPSHOT` lifecycle gate while revalidating account View metadata. A standalone `DROP ACCOUNT` already enters the `SNAPSHOT` lineage lifecycle barrier before acquiring the same account-name lock. Concurrent CREATE/DROP of one account could therefore form a distributed lock cycle. Take the existing `SNAPSHOT` gate at the beginning of CREATE's owned transaction, before the account-name lock. This preserves DROP's owner publication barrier and aligns CREATE, DROP, and data-branch target-account locking to one order: ``` SNAPSHOT lifecycle gate -> __mo_account_lock ``` The compatibility behavior for deployments where the View metadata catalog is not available is retained: when View metadata refresh is disabled, missing catalog-table errors still bypass the optional gate. Approved by: @XuPeng-SH
`CREATE ACCOUNT` acquired the per-account `__mo_account_lock` first and later entered the global `SNAPSHOT` lifecycle gate while revalidating account View metadata. A standalone `DROP ACCOUNT` already enters the `SNAPSHOT` lineage lifecycle barrier before acquiring the same account-name lock. Concurrent CREATE/DROP of one account could therefore form a distributed lock cycle. Take the existing `SNAPSHOT` gate at the beginning of CREATE's owned transaction, before the account-name lock. This preserves DROP's owner publication barrier and aligns CREATE, DROP, and data-branch target-account locking to one order: ``` SNAPSHOT lifecycle gate -> __mo_account_lock ``` The compatibility behavior for deployments where the View metadata catalog is not available is retained: when View metadata refresh is disabled, missing catalog-table errors still bypass the optional gate. Approved by: @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28433
What this PR does / why we need it:
CREATE ACCOUNTacquired the per-account__mo_account_lockfirst and laterentered the global
SNAPSHOTlifecycle gate while revalidating account Viewmetadata. A standalone
DROP ACCOUNTalready enters theSNAPSHOTlineagelifecycle barrier before acquiring the same account-name lock. Concurrent
CREATE/DROP of one account could therefore form a distributed lock cycle.
Take the existing
SNAPSHOTgate at the beginning of CREATE's ownedtransaction, before the account-name lock. This preserves DROP's owner
publication barrier and aligns CREATE, DROP, and data-branch target-account
locking to one order:
The compatibility behavior for deployments where the View metadata catalog is
not available is retained: when View metadata refresh is disabled, missing
catalog-table errors still bypass the optional gate.
Validation:
go test -mod=readonly -list '^TestInitGeneralTenantLocksSnapshotBeforeAccountName$' ./pkg/frontendgo test -mod=readonly -ldflags="..." -v -count=1 -timeout=5m -run '^TestInitGeneralTenantLocksSnapshotBeforeAccountName$' ./pkg/frontendmake dev-upcluster on 10.1.222.50.20701or a deadlock; final account residue was 0.The focused UT is intentionally an ordering/error-path test. The two-CN SQL
replay supplies the public distributed-lock validation without adding a
timing-dependent BVT.