Repository navigation
fix(lockservice): report all waiters in mo_locks - #32631
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
LeftHandCold
left a comment
There was a problem hiding this comment.
Review 结论:对 main@b9c06b27b0d7 → 91a7b5bd1243 的三个变更文件及相关调用链完成复核,未发现需要阻断的代码问题,支持这个最小修复。当前账号与作者相同,因此提交 COMMENT,不作为独立 reviewer 的 APPROVE,也不代替 CI 合并门禁。
正确性与设计
- 根因和改动匹配:底层 queue.iter 在 false 时停止,handleGetLockInfo 的回调在成功收集一个 waiter 后返回 true;旧包装函数取反导致只收集首项。直接透传回调结果恢复了统一的继续/停止契约。
- 检查了仓库内全部 IterWaiters 调用点:完整收集/计数者返回 true,存在性/指定事务查找在命中后返回 false,没有发现依赖旧反转语义的调用方。IterHolders 的语义也一致。
- 生产调用方是 CN 锁信息枚举;本地/远程死锁等待图遍历使用底层 waiters.iter,不经过这个包装函数。没有修改持锁、唤醒、排队、公平性或死锁检测算法。
- 属于局部 bug fix,无需新增设计框架。没有增加状态机、存储、缓存、后台任务或另一条执行路径。
资源、并发与性能
| 检查 | 结论 |
|---|---|
| Q1 清理 | 生产枚举不消费 waiter、不改变引用计数;RPC 响应通过现有 copyWaitTxn 复制事务 ID,不暴露 pooled waiter。测试逐轮回滚事务、取消等待者并收回 worker,再清理数据库。 |
| Q2 等待 | 保留原有 table → queue 的读锁顺序,回调只构造结果,不引入 RPC/通知等待;测试结果 channel 容量覆盖两个 worker,断言失败后也可收尾。 |
| Q3 增长 | 不新增常驻容器;诊断结果随本次查询及当前锁/等待者集合存在。 |
性能不是完全零变化:诊断请求现在正确遍历全部 W 个 waiter,而不是错误地只看一个,因此读锁持有时间、响应大小增加;现有 SQL 展开在多 holder 场景下是 H×W 行。这个成本属于完整诊断结果的成本,并未向普通加锁/解锁路径增加额外枚举或同步。未做生产级大队列性能保证。
测试与 CI 边界
- 7 个轻量 UT 覆盖空/单/多 waiter、两种 early-stop 和 committed-prefix,不需要 pooled waiter 或服务启动。
- SQL 测试使用已有单 CN fixture、一个 holder 和两个 waiter;先从独立事务视图确认同表同 key,再通过不调用 IterWaiters 的底层队列探针确认真正入队,最后检查两个公共锁视图。这个到达条件不是被测接口自证。
- 验证精确 waiter ID/key、无重复结果、正常锁接力、全部释放,并在同一张表重复两轮;没有增加生产测试钩子或昂贵拓扑。
- 本次复用了可核验的 exact-head CI 证据,未重复启动本地整套 UT。首轮普通 UT 日志明确记录新增 TestMoLocksListsAllWaiters PASS,5.14 s:job。同 SHA 的 coverage job 及报告为 exit 0、无失败事件:coverage。SCA、shared build、compose/proxy 与 pessimistic BVT 也已成功。
- 但不能宣布 CI 全绿:首轮普通 UT 在 embed/sqlintegration 的其他测试有失败,抽查包括 collations 的 context deadline exceeded 和 charset 用例的 connection already closed;普通 UT 正在第二次运行。尚未证明这些失败的根因,不能直接归类成环境或既有问题,也不能用 coverage 通过替代普通 UT 的最终结果。
当前没有人工 review thread 待解决。该 PR 修复 #32617 的诊断漏报,不证明此前业务事故的根因已修复;目标分支是 main,不会自动将此修复带入 4.2。
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 91a7b5bd1243fc197ba362749788a67aa9f885a6
Assessment: approve
Direct callback pass-through restores the queue's existing continuation contract. All callers align, and existing locking, copying and ownership remain authoritative. No new mechanism or actionable finding remains.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed all three changed files, every IterWaiters caller, the RPC/SQL consumers, issue 32617 and all four discussion entries.
-
Reused exact-head successful ordinary UT, coverage, shared-build and SCA results. The supplied review records TestMoLocksListsAllWaiters PASS in real MySQL CI.
-
Reused reported Go 1.27.1 lockservice package validation and SQL race validation: measured 7.58s, then three repetitions.
-
Local formatting, diff, frozen-source and evidence/ledger checks passed; receipts and logs are reconciled in validation-audit.json.
Limitations:
-
Runtime validation was reused from frozen CI and author/reviewer evidence; no fresh local Go test run.
-
The SQL regression uses one CN; this fixes diagnostic enumeration, without a backport or underlying-incident claim.
✅ Merged into
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32617
What this PR does / why we need it:
Lock.IterWaitersnegates the callback result even though its queue iteratorand callers use
trueto continue.handleGetLockInfotherefore records onewaiter and silently stops, making
mo_locks()andmo_catalog.mo_locksincomplete when multiple transactions wait on the same lock.
Pass the callback result through unchanged and document early termination.
This restores the existing contract without changing queue ownership,
locking, notification, deadlock detection, RPC formats, or persisted data.
Repository callers have been checked; actual deadlock detection traverses
the underlying queue directly and is not affected by this wrapper defect.
Regression coverage:
the committed-prefix boundary without consuming queue entries.
An independent transaction view plus the underlying queue establishes
arrival before either public lock view is checked. It verifies both waiter
IDs/keys, normal handoff, and final lock release, twice on the same table.
It reuses the canonical single-CN fixture; the defect is in owner-side
enumeration, not cross-CN routing. The scenario body takes about 145 ms
normally (about 4.7 s including isolated fixture startup/teardown).
Local validation on Linux amd64 / Go 1.27.1, based on Main
b9c06b27b0d7384ca31ce67edd43f764152d56d2:reports
expected: 2, actual: 1after independently confirming both waiters../pkg/lockservicepackage passes (66 s).TestDeadlockMySQLRetryIdentityand the new SQL test pass together.-race, then three repetitions in one processalso pass (adaptive 30 s budget; initial test duration 7.58 s).
go vetand repository-configured golangci-lint pass for thechanged packages; consumer
pkg/cnservicelint also passes.This fixes missing diagnostic wait edges, not the underlying incidents that
those diagnostics investigate. No data-loss, OOM, or broken lock-exclusion
claim is made. This PR targets Main only.