Skip to content

[Bug]: TN lockservice keeps fencing a CN after hot recreation #25650

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

2865ed6

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

  1. Start the Docker multi-CN local-disk cluster.
  2. Run a long transaction or continuous writes through both CNs.
  3. Force-recreate both CN containers without restarting TN.
  4. Observe the CNs call lockservice.Resume() after recovery.
  5. Wait for TN orphan-transaction cleanup cycles.
  6. Before the fix, TN can repeatedly return 20708 (CannotCommitOnInvalidCN) and abort the long-running transaction.

Additional Information

Root cause combines three independent races:

  1. MORPC pools by hostname, and an asynchronous pre-reset backend-create request can republish a stale backend after targeted reset.
  2. In a long-lived CGO process, hostname resolution can remain stale across Docker endpoint recreation.
  3. Cleanup fencing and Resume were 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

  1. added
    kind/bug
    on Jul 13, 2026
  2. added a commit that references this issue on Jul 14, 2026
    67898b6
  3. added
    severity/s0
    and removed on Jul 14, 2026
  4. added theissue type on Jul 14, 2026
  5. added this to the MO-202607 milestone on Jul 14, 2026
  6. Ariznawlll commented on Jul 14, 2026

    @Ariznawlll
    Collaborator

    已在最新 main 上完成针对性白盒验证。

    验证版本

    • 分支:main
    • Commit:0977fc07c51067ce76b769c7853d7374cb2fccec
    • 验证时间:2026-07-14(Asia/Shanghai)

    验证方法

    执行 clusterservice、morpc、lockservice 中与 CN 热重建恢复直接相关的回归,重点覆盖 stale backend、endpoint reset、negative confirmation、Resume/fence epoch 竞争:

    go test ./pkg/clusterservice ./pkg/common/morpc ./pkg/lockservice \
      -run 'TestCleanCommitState|TestResetBackend|TestValidRemoteTxn' -count=1 -v

    实际结果

    CleanCommitState 的重试/确认、ResetBackend 的 endpoint 刷新、ValidRemoteTxn 的 stale route 恢复以及 Resume 后禁止旧 cleanup 再次 fence 等关键用例均通过。

    结论与边界

    当前 main 已满足修复对应的白盒行为:旧 backend 不会在 reset 后重新污染连接池,失效响应会经过重新解析与确认,旧 cleanup 也不能在 Resume 后重新 fence CN。此次没有重新构建 Docker 双 CN 并强制交换容器 IP,因此这是确定性回归验证,不是完整热重建环境复验。

    #25650 verification

  7. added 6 commits that reference this issue on Sep 17, 2026
    61e293b
    8ce0958
    3bca9e8
    7036e79
    cb37426
    b709d79
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