Repository navigation
Closed as not planned
Labels
kind/bugSomething isn't workingseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.
Milestone
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main (commit: 2add0b9)
Commit ID
Other Environment Information
- Hardware parameters: CI environment
- OS type: Linux
- Others: BVT test environment
Actual Behavior
CI BVT 测试中 DROP ACCOUNT 操作有概率卡住(hung),导致测试超时失败。
代码分析 — doDropAccount 执行流程(pkg/frontend/authenticate.go:3988):
- 开启事务 (
begin) - 对
mo_catalog.__mo_account_lock表加行锁 (SELECT ... FOR UPDATE) - 依次删除账户相关的系统表数据(mo_user, mo_role, mo_user_grant 等)
- 删除 publication / subscription
- 更新 mo_ccpr_log
- 逐个删除用户创建的数据库
- 删除 mo_mysql_compatibility_mode, mo_indexes, mo_table_partitions, mo_foreign_keys
- 删除 pitr 记录
- 从 mo_account 删除账户记录
- 提交事务
潜在卡住原因:
-
锁竞争:
lockMoAccountNameFormat(authenticate.go:1248)使用SELECT ... FOR UPDATE对 account name 加行锁。如果有其他并发事务持有该锁(如 CREATE/ALTER ACCOUNT、snapshot restore),会阻塞等待lock_wait_timeout(默认最大值 31536000 秒 ≈ 1 年)。 -
长事务 + DDL 阻塞:整个操作在单个大事务中执行大量 DDL,如果账户下有多个数据库,每个数据库删除本身也是重量级操作,可能导致事务长时间持锁。
-
lock_wait_timeout 默认值过大:
pkg/frontend/variables.go:2167中lock_wait_timeout的范围是[1, 31536000],如果默认设为最大值,等锁时几乎等于无限等待。
Expected Behavior
DROP ACCOUNT 应在合理时间内完成,或在超时后返回明确的错误信息,而不是无限期等待。
Steps to Reproduce
- 运行 BVT 测试套件
- 执行涉及 DROP ACCOUNT 的测试用例
- 有一定概率测试卡住直到超时
Additional information
相关代码位置:
pkg/frontend/authenticate.go:3988—doDropAccount函数pkg/frontend/authenticate.go:1248—lockMoAccountNameFormatSQLpkg/frontend/authenticate.go:1729—getSqlForLockMoAccountNameFormat函数pkg/frontend/variables.go:2167—lock_wait_timeout定义
相关历史修复:
- fix txn deadlock during drop account #20580, fix txn deadlock during drop account #20579: fix txn deadlock during drop account
- fix drop account error #18500: fix drop account error
建议排查方向:
- 检查 CI 中是否有其他并发操作(snapshot restore、CREATE/ALTER ACCOUNT)持有
__mo_account_lock上的行锁 - 考虑对 drop account 的锁等待设置更合理的超时
- 检查长事务中 DDL 的锁等待链路
- 增加锁等待的日志输出以便定位
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't workingseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.
Activity
aptend commentedon Jun 25, 2026
Investigation result: this does not look like a real
DROP ACCOUNThang in MatrixOne.For the failed job
83331485042,diff_6.sqlstarted at2026-06-25 00:48:13.853and mo-tester reported the error at00:48:14.844; the whole script file cost was only2.587s. So it did not actually wait for300000 ms.The docker logs show
cn-0restarted duringdrop account acc1:cn-0.loghas an initial start at00:39:33and anotherMO logger initat00:48:15.cn-1/logservicesawdial tcp 172.18.0.5:6001: connect: connection refusedaround00:48:14.docker pslater showed onlycn-0asUp 22 minutes, whilecn-1,tn, andlogservicewereUp 31 minutes.I also checked mo-tester code. The message
MO does not return result in 300000 msis printed whenstatement.execute()throwsSQLExceptionand thenconnection.isClosed()or!connection.isValid(10)is true. The300000is just the configured JDBCsocketTimeout; it is not proof that mo-tester waited for 5 minutes. A server restart / connection loss can hit this exact branch and produce the misleading timeout text.The current artifacts do not preserve the actual
cn-0exit reason: no Go panic stack, no obvious OOM kill in dmesg, nodocker inspectstate, and the debug pprof was already unreachable.So I am closing this as not a confirmed MatrixOne
DROP ACCOUNThang. The actionable fix is in mo-tester: distinguish connection loss from real socket/query timeout and include the original JDBC error in the report.