Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- Deployment: Docker multi-CN local-disk setup
- Topology: one TN and two CN services
- Failure injection: force-recreate both CN containers while preserving their hostnames and CN UUIDs
Actual Behavior
After both CN containers are hot-recreated, their Docker IPs can swap while the hostnames and CN UUIDs remain stable. The long-lived TN process can keep using a stale hostname/backend resolution for GetActiveTxn. Orphan-transaction cleanup then repeatedly treats the CN as unreachable and fences it. The recreated CN calls Resume, but a stale cleanup result can race with that request and fence the CN again. Commits eventually fail with error 20708 and long-running transactions are asynchronously aborted.
A second failure mode appears after recovery has pinned an IP: on a later IP swap, that stale IP can belong to another healthy CN. The RPC succeeds but returns Valid=false for the target service, which was incorrectly treated as an authoritative negative response.
Expected Behavior
A CN hot recreation must not leave TN permanently fencing a healthy recreated CN. Cleanup must refresh the affected backend, re-resolve the endpoint without relying on stale CGO resolver state, and confirm a negative GetActiveTxn response before discarding transaction-control state. Cancellation, timeouts, and backend recreation races must remain bounded.
Steps to Reproduce
- Start the Docker multi-CN local-disk cluster.
- Run a long transaction or continuous writes through both CNs.
- Force-recreate both CN containers without restarting TN.
- Observe the CNs call
lockservice.Resume()after recovery. - Wait for TN orphan-transaction cleanup cycles.
- Before the fix, TN can repeatedly return 20708 (
CannotCommitOnInvalidCN) and abort the long-running transaction.
Additional Information
Root cause combines three independent races:
- MORPC pools by hostname, and an asynchronous pre-reset backend-create request can republish a stale backend after targeted reset.
- In a long-lived CGO process, hostname resolution can remain stale across Docker endpoint recreation.
- Cleanup fencing and
Resumewere not linearized, so an old cleanup could re-fence a resumed CN.
The fix adds epoch-protected targeted backend invalidation, a bounded pure-Go DNS recovery lookup for GetActiveTxn, one reset-and-retry confirmation for Valid=false, context-aware bounded retries, and deterministic regression/race tests.
Activity
fix(lockservice): recover active txn checks after CN recreation (#25651)
Ariznawlll commentedon Jul 14, 2026
已在最新
main上完成针对性白盒验证。验证版本
main0977fc07c51067ce76b769c7853d7374cb2fccec验证方法
执行
clusterservice、morpc、lockservice中与 CN 热重建恢复直接相关的回归,重点覆盖 stale backend、endpoint reset、negative confirmation、Resume/fence epoch 竞争:实际结果
CleanCommitState的重试/确认、ResetBackend的 endpoint 刷新、ValidRemoteTxn的 stale route 恢复以及 Resume 后禁止旧 cleanup 再次 fence 等关键用例均通过。结论与边界
当前 main 已满足修复对应的白盒行为:旧 backend 不会在 reset 后重新污染连接池,失效响应会经过重新解析与确认,旧 cleanup 也不能在 Resume 后重新 fence CN。此次没有重新构建 Docker 双 CN 并强制交换容器 IP,因此这是确定性回归验证,不是完整热重建环境复验。
fix(morpc): wake waiters when backend creation completes (#25771)
fix(lockservice): recover active txn checks after CN recreation (matr…
fix(morpc): wake waiters when backend creation completes (matrixorigi…
fix(lockservice): recover active txn checks after CN recreation (matr…
fix(morpc): wake waiters when backend creation completes (matrixorigi…
fix(lockservice): recover active txn checks after CN recreation (matr…
fix(morpc): wake waiters when backend creation completes (matrixorigi…