Skip to content

[Bug]: DROP ACCOUNT 操作在 CI BVT 测试中有概率卡住(hung) #25140

Closed as not planned

Description

@matrix-meow

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main (commit: 2add0b9)

Commit ID

2add0b9

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):

  1. 开启事务 (begin)
  2. 对 mo_catalog.__mo_account_lock 表加行锁 (SELECT ... FOR UPDATE)
  3. 依次删除账户相关的系统表数据(mo_user, mo_role, mo_user_grant 等)
  4. 删除 publication / subscription
  5. 更新 mo_ccpr_log
  6. 逐个删除用户创建的数据库
  7. 删除 mo_mysql_compatibility_mode, mo_indexes, mo_table_partitions, mo_foreign_keys
  8. 删除 pitr 记录
  9. 从 mo_account 删除账户记录
  10. 提交事务

潜在卡住原因:

  1. 锁竞争:lockMoAccountNameFormat(authenticate.go:1248)使用 SELECT ... FOR UPDATE 对 account name 加行锁。如果有其他并发事务持有该锁(如 CREATE/ALTER ACCOUNT、snapshot restore),会阻塞等待 lock_wait_timeout(默认最大值 31536000 秒 ≈ 1 年)。

  2. 长事务 + DDL 阻塞:整个操作在单个大事务中执行大量 DDL,如果账户下有多个数据库,每个数据库删除本身也是重量级操作,可能导致事务长时间持锁。

  3. lock_wait_timeout 默认值过大:pkg/frontend/variables.go:2167 中 lock_wait_timeout 的范围是 [1, 31536000],如果默认设为最大值,等锁时几乎等于无限等待。

Expected Behavior

DROP ACCOUNT 应在合理时间内完成,或在超时后返回明确的错误信息,而不是无限期等待。

Steps to Reproduce

  1. 运行 BVT 测试套件
  2. 执行涉及 DROP ACCOUNT 的测试用例
  3. 有一定概率测试卡住直到超时

Additional information

相关代码位置:

  • pkg/frontend/authenticate.go:3988 — doDropAccount 函数
  • pkg/frontend/authenticate.go:1248 — lockMoAccountNameFormat SQL
  • pkg/frontend/authenticate.go:1729 — getSqlForLockMoAccountNameFormat 函数
  • pkg/frontend/variables.go:2167 — lock_wait_timeout 定义

相关历史修复:

建议排查方向:

  1. 检查 CI 中是否有其他并发操作(snapshot restore、CREATE/ALTER ACCOUNT)持有 __mo_account_lock 上的行锁
  2. 考虑对 drop account 的锁等待设置更合理的超时
  3. 检查长事务中 DDL 的锁等待链路
  4. 增加锁等待的日志输出以便定位

Activity

  1. added
    kind/bug
    on Jun 25, 2026
  2. added
    severity/s0
    and removed on Jun 25, 2026
  3. added theissue type on Jun 25, 2026
  4. added this to the MO-202606 milestone on Jun 25, 2026
  5. aptend commented on Jun 25, 2026

    @aptend
    Contributor

    Investigation result: this does not look like a real DROP ACCOUNT hang in MatrixOne.

    For the failed job 83331485042, diff_6.sql started at 2026-06-25 00:48:13.853 and mo-tester reported the error at 00:48:14.844; the whole script file cost was only 2.587s. So it did not actually wait for 300000 ms.

    The docker logs show cn-0 restarted during drop account acc1:

    • cn-0.log has an initial start at 00:39:33 and another MO logger init at 00:48:15.
    • cn-1 / logservice saw dial tcp 172.18.0.5:6001: connect: connection refused around 00:48:14.
    • docker ps later showed only cn-0 as Up 22 minutes, while cn-1, tn, and logservice were Up 31 minutes.

    I also checked mo-tester code. The message MO does not return result in 300000 ms is printed when statement.execute() throws SQLException and then connection.isClosed() or !connection.isValid(10) is true. The 300000 is just the configured JDBC socketTimeout; 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-0 exit reason: no Go panic stack, no obvious OOM kill in dmesg, no docker inspect state, and the debug pprof was already unreachable.

    So I am closing this as not a confirmed MatrixOne DROP ACCOUNT hang. The actionable fix is in mo-tester: distinguish connection loss from real socket/query timeout and include the original JDBC error in the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions