Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
- First failing Daily:
39225f5fbc63b44a190cdd43f954ee07d78e6cdc - Current official main revalidated:
4b43f8c99bb22e6a35c389c93bf64c2dc043feaf - Regression-introducing merge:
e78ff09781e1bc56991d0cd315cfb3031c2dc429(#28322)
Other Environment Information
- Daily: distributed deployment, 3 CN / 1 TN / 3 LogService / 2 Proxy.
- Runtime reproduction: clean two-CN
make dev-updeployment on host 50, built from the exact first-failing Daily SHA. The source worktree was clean and no hook or product-code change was used. - Daily workload:
mo-loadcases/ddl/create_drop_account, with 10 CREATE and 10 DROP workers sharing the namesacount_0throughacount_9.
Actual Behavior
After #28322 merged, concurrent lifecycle operations for the same account name can form an internal lock cycle and return ERROR 20701 (HY000): deadlock detected.
The first failing Main Concurrent Daily started the normal account workload at 2026-09-08 03:51 UTC. It reported 83 20701 errors:
CREATE ACCOUNT: 268 success, 46 errors
DROP ACCOUNT: 118 success, 37 errors
The four immediately preceding Main Concurrent Daily runs had no 20701 in this normal account case.
The real frontend path reproduces on the exact Daily SHA with only two sessions:
Connection A: CREATE ACCOUNT IF NOT EXISTS account_cycle_39225 ...
150 ms later
Connection B: DROP ACCOUNT IF EXISTS account_cycle_39225
Observed:
CREATE: ERROR 20701 (HY000): deadlock detected
DROP: success
Expected Behavior
CREATE ACCOUNT and DROP ACCOUNT for the same name may serialize, but the account lifecycle gates must use one consistent order. The operations must not create an avoidable internal deadlock and fail with 20701.
Steps to Reproduce
1. Check out 39225f5fbc63b44a190cdd43f954ee07d78e6cdc.
2. Run `make dev-build` and `make dev-up` to start the standard two-CN local deployment.
3. Through Proxy, start:
CREATE ACCOUNT IF NOT EXISTS account_cycle_39225
ADMIN_NAME admin IDENTIFIED BY '111';
4. About 150 ms later, from a separate connection, run:
DROP ACCOUNT IF EXISTS account_cycle_39225;
5. Observe `ERROR 20701 (HY000): deadlock detected` from CREATE.
6. Run `make dev-down` after the check.
Additional information
Confirmed root cause
#28322 changed inheritViewMetadataRevalidation so the late part of each CREATE ACCOUNT transaction calls lockViewMetadataLifecycle, which acquires the SNAPSHOT gate and then the View gate.
The relevant CREATE ACCOUNT transaction already acquired the row in mo_catalog.__mo_account_lock at its beginning. Conversely, standalone DROP ACCOUNT enters lockDataBranchLineageOwnerLifecycle at transaction admission, whose lineage write barrier updates the same SNAPSHOT row, and only then locks __mo_account_lock.
CREATE holds account-name lock -> waits for SNAPSHOT
DROP holds SNAPSHOT -> waits for account-name lock
This is an executable two-transaction cycle; the real SQL reproduction above invokes the actual frontend CREATE/DROP paths, including DROP's internal lineage write barrier.
Current official main keeps this ordering. No commit after the failing Daily changed this closure.
Scope
#28322 correctly fixed the original View/SNAPSHOT inversion tracked by #28317; its focused test passing is expected. That test does not interleave the account-name gate, so it cannot detect this new account-name/SNAPSHOT inversion.
#28079 remains related but separate: it tracks global View-gate serialization and high account-lifecycle latency. This issue tracks the deterministic lock-order deadlock and 20701 regression.
Do not move the DROP lineage barrier after the account-name lock: it protects snapshot/PITR/data-branch owner publication. A safe fix must instead make CREATE acquire the existing Snapshot lifecycle gate before its account-name lock, while retaining the required Snapshot -> View order later in the transaction.
The Daily's server-side transaction IDs and wait graph were not retained in Loki, so the exact original victim edge is unavailable. The source-level graph and exact-SHA real-frontend reproduction independently prove reachability and the observed error.
Duplicate searches: "deadlock detected" "CREATE ACCOUNT", "__mo_account_lock" SNAPSHOT, and "SnapshotLifecycleGateSQL" account. Related issues read: #28317, #28079, #25140.
Activity
LeftHandCold commentedon Sep 8, 2026
已提交修复 PR #28436。修复将 CREATE ACCOUNT 的生命周期取锁顺序改为 SNAPSHOT -> __mo_account_lock,与 standalone DROP ACCOUNT 和 data-branch target-account 路径一致。已在 50 的双 CN PR 镜像环境按原始 150ms CREATE/DROP 交错验证 13 次,均无 20701 且无账户残留。