Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Searched open and closed issues for IterWaiters, mo_locks waiter,
mo_locks missing, and waiters first. #30315 concerns actual waiter lifecycle
and lost wakeups, not the diagnostic iterator's callback contract. This finding
was discovered while investigating #32515; it does not explain that incident's
zero-row allocator reads.
Branch Name
4.2-dev (real multi-CN SQL observation); main-derived source also inspected.
Commit ID
- Runtime:
a7bc2008e9236708fee0328376f2c2c6b6f0d3fc. - Main-derived discovery worktree:
fix/ddl-lifecycle-gate-order-28317at
00e639e9f96b67a3d3f74d3be474442ce30da74e, same iterator behavior by source
inspection. No current-main SQL reproduction is claimed.
Other Environment Information
- Linux, isolated Docker deployment, one LogService, one TN, three CNs.
- Exact incident image digest:
sha256:56a64cbbb7a86ada87c4e1af656791be329714ef0fe60e3ecae1aa8955432ee8. - Tenant-owned auto-increment metadata row; no restart or injected fault is
required for the observed diagnostic discrepancy.
Actual Behavior
With a holder and two pending requests on the same encoded point key,
mo_transactions() reports the two pending transactions on different CNs, but
mo_locks() reports only the first waiter. An initial probe showed two waiting
transactions on the same table but only one reported lock waiter over about
15 seconds. A corrected follow-up also captured the exact encoded waiting key
for both transactions, before any CN was frozen.
Observed in the follow-up probe on 2026-11-12 at 08:08:34.805211 UTC:
metadata table: 272552
encoded point key: 4601401704290746016100ff00
holder: b4b2ea7754b2575518e73dc7c67b5af0
waiting on owner CN: a1d578f0d8b0aafd18e73dc7c69e32e2
waiting on other CN: bae2e33a6f0436c118e73dc7c9e19106
mo_transactions: both waiter transaction IDs, same table and lock_content
mo_locks: holder plus only a1d578f0d8b0aafd18e73dc7c69e32e2
These are synthetic test identities. Raw SQL observations and frozen scripts
were preserved. The discrepancy was encountered before freezing any CN. The
initial probe stopped at its observation gate; the follow-up proceeded after
using the transaction registry as an independent arrival check.
Expected Behavior
The lock observation API should enumerate all committed waiter queue entries
when its callback requests continuation. It should not silently hide the second
and subsequent waiters.
Steps to Reproduce
- On CN-A, BEGIN and SELECT one existing row FOR UPDATE; keep the transaction
open. In our probe this was a tenant administrator selecting the target
(table_id, col_name)from itsmo_catalog.mo_increment_columnstable. - On CN-B and CN-C, issue the same SELECT FOR UPDATE asynchronously. Confirm
both transactions are waiting for the holder's exact encoded key using
mo_transactions()(cn_id,txn_id,table_id,lock_content). - Query
mo_locks()for the physical metadata table and match its acquired
point lock and holder transaction. Only one waiting transaction is listed. - Roll back the holder and close the waiting sessions after collecting the
observation. No modification to metadata is needed.
Additional information
Proven code mechanism
Lock.IterWaiters at the observed revision
negates the callback result:
func (l Lock) IterWaiters(fn func(waiter pb.WaitTxn) bool) {
l.waiters.iter(func(w *waiter) bool {
return !fn(w.txn)
})
}The queue iterator
stops on false. cnservice.handleGetLockInfo appends the waiter and returns true.
Thus the first append becomes false at the queue boundary and ends enumeration.
The holder iterator uses true-to-continue, which is also what the caller expects.
The main-derived worktree
still has the inversion, and its handleGetLockInfo callback still returns true.
Impact and boundaries
- Incorrect/incomplete diagnostic results can mislead wait-graph investigation
and prevent tests from establishing that two real waiters have arrived. - This does not establish that the underlying queue lost a waiter, that locking
or deadlock detection is broken, or that business data is missing. - No first-bad PR is identified; no recent regression is claimed.
- No production fix is included here. Suggested validation: an iterator test
with at least two waiters and a multi-sessionmo_locks()integration check;
also verify early-stop callback behavior and other callers before changing it.
Activity
fix(lockservice): report all waiters in mo_locks (#32631)
XuPeng-SH commentedon Nov 12, 2026
QA 交接(main,待验证,不代表验收通过)
关联修复 #32631 已于 2026-11-12 20:48 UTC 合入 main,merge SHA:
c2f82ede552391104fb965569d54d83235a38207。Lock.IterWaiters现在直接透传回调结果,恢复 true 继续、false 停止的既有队列契约,解决mo_locks()/mo_catalog.mo_locks只枚举首个 waiter 的诊断漏报。验证证据及限制:本次交接仅核对远端合并状态、完整 issue 评论与 PR 修改/验证记录,没有运行本地测试。作者报告 Linux amd64 / Go 1.27.1 下,旧实现的单位反例与真实 SQL 双 waiter 测试失败,修复后 7 个迭代边界、完整 lockservice 包、SQL/race 重复测试及增量静态检查通过;PR 审查记录复用了此前 head 的 CI/作者证据。不能将这些历史结果写成 merge SHA 上本轮实测。合并队列记录显示 CI Required 条件满足。
建议 QA 在包含上述 SHA 的 main 上复验:一个 holder 与至少两个 waiter 争用同表同编码 key,以独立事务视图确认到达后,核对两个锁视图的完整 waiter ID/key、无重复、正常接力及释放;覆盖空/单/多 waiter、early-stop、重复轮次,并补原始多 CN 场景和较长队列下诊断开销。已提交 SQL 回归使用单 CN,不代表跨 CN 或生产规模已验证。
范围边界:修复仅针对诊断枚举,不证明 #32515、#30315 等底层业务事故、锁生命周期或死锁问题已修复。原 issue 的 4.2-dev 观测不是当前 main 修复的反例,也不说明 4.2 已包含此变更;此次仅交接 main 验证,不自动要求 backport。当前未发现针对此 main 修复尚未完成的开发 follow-up 或适用的已验证反例。
Ariznawlll commentedon Nov 12, 2026
测试版本
main:c2f82ede552391104fb965569d54d83235a38207,包含修复 fix(lockservice): report all waiters in mo_locks #32631;测试时逐个核对各 CN 的git_version()完整值。原问题验证
复现原始租户自增元数据行场景:CN1 在事务内持有
mo_catalog.mo_increment_columns对应(table_id, col_name)的行锁;CN2 和 CN3 分别请求相同行锁。通过mo_transactions()独立确认两个等待事务已经到达、CN 不同且 encoded key 相同后,分别查询mo_locks()和mo_catalog.mo_locks,比对完整 waiter 事务 ID、key、holder 和记录数。连续 3/3 轮两个视图均返回两个等待者且无重复;释放 holder 后两个等待事务均正常完成。见 三 CN 原场景运行。Happy Path 覆盖
Unhappy Path 和白盒覆盖
TestLockIterWaiters在-race -count=3下 3/3 通过,覆盖 empty、one、all、stop-first、stop-second、uncommitted 和 committed-prefix,验证 true 继续与 false 提前停止。见 完整成功的定向运行。本项验证的是诊断枚举和受控接力,不将其扩展为死锁检测、所有锁故障或 [Bug]: incrservice: 4.2 AP CN exits on zero-row allocator reads during concurrent primary-key UPDATE #32515 的通过结论。回归测试
main 专用的 MOTR PR #329 增加
issue_32617_lock_waiters;在两个 CN 分别重复 3 次,相关两条 MOTR 用例合计在每个入口均为 6/6,无跳过。独立三 CN 元数据测试也已加入该 PR 的定向 CI。PR 尚待合入,按约定先完成 Issue 处理;不将单个定向步骤通过写成整个 PR CI 全绿。测试结论
main 验收通过。 原始三 CN 租户元数据问题、常规行锁多等待者与白盒回调边界均已覆盖;三 CN 同机且 32 等待者只属有限规模,不代表跨物理节点的长期压力测试。4.2-dev 修复及验收不在本次结论范围内。