Skip to content

[Bug]: HAKeeper shuts down healthy LogService voters after heartbeat client sticks to isolated address #32134

Closed

Description

@jiangxinmeng1

Description

With a three-voter LogService cluster and a 30-second test log-store-timeout, HAKeeper can classify a running, Raft-reachable store as expired after its shared heartbeat client keeps trying an isolated address. HAKeeper then schedules L/shutdown for all three stores; in repeated tests an otherwise healthy store actually exited. The data and HAKeeper Raft majority had remained available before the control-plane shutdown.

Environment

  • MatrixOne upstream/main at d61a7206c16b30baa4efc525eb6067c4364035aa.
  • Three independent, fresh-data-directory test clusters on 10.222.1.51; each had one data shard with three voters and a three-voter HAKeeper shard. Each process ran in a separate Linux network namespace. A direct three-address Append → Read client supplied continuous load; no TN/CN was started.
  • Accelerated test setting log-store-timeout = "30s". Production default is 5 minutes. A separate fresh-cluster 330-second isolation with the default 5-minute setting did not reproduce L/shutdown.

Reproduction

  1. Start three LogService voters with log-store-timeout = "30s"; verify the data and HAKeeper three-member views and continuous Append → Read progress.
  2. Isolate the current HAKeeper leader bidirectionally for about 90 seconds with netns.sh <cluster-root> down <leader-index>, leaving the other two nodes mutually reachable. Restore it and wait for three-member discovery again.
  3. Identify the new HAKeeper leader. Run ip netns exec <surviving-node-namespace> ss -tnp to record that a surviving node's HAKeeper RPC connection points at a candidate node.
  4. Isolate that connected node for 80–90 seconds, keeping the other two processes and their mutual network alive. The candidate may be the new leader or a follower. Inspect failed to send log service heartbeat, Expired logStore info, L/shutdown, and Shutdown complete in all three logs.

A single leader isolation was a negative control in the fresh clusters. The second isolation with a captured client connection to the fault target is the trigger observed here; an arbitrary one-node outage is not a sufficient reproduction description.

Actual Result and Repetition

The targeted isolation after an initial leader outage reproduced in 3/3 independent fresh clusters:

Cluster Targeted isolation False expiry and shutdown
heartbeat-repeat-20261104 New HAKeeper leader node2; node0's client TCP connected to node2 At 11:29:32, syshealth listed running node0 and isolated node2 as expired and scheduled L/shutdown for all three stores; node1 completed shutdown at 11:29:40.
heartbeat-repeat2-20261104 New leader node2; node0 and node1 client TCP connected to node2 At 11:34:11, syshealth listed running node0 and isolated node2 as expired, scheduled shutdown for all three; node1 exited at 11:34:19.
heartbeat-repeat3-20261104 New leader node0; its client TCP remained connected to follower node1, then node1 was isolated At 11:39:20, syshealth listed running node0 and isolated node1 as expired, scheduled shutdown for all three; never-isolated node2 exited at 11:39:30.

The single leader outages in each cluster did not produce the false shutdown; an additional isolated-follower trial in the first cluster also did not. The first cluster therefore required a third outage before its targeted positive trial. This bounds the stability claim to the captured-connection, two-stage sequence. The continuously writing client and Raft member queries showed two-voter progress before the erroneous shutdown, so the expiry of the surviving node was not caused by loss of Raft majority.

Expected Result

When two LogService/HAKeeper voters can still communicate, a stale heartbeat RPC connection should fail over to a reachable HAKeeper endpoint. An isolated store may legitimately expire under the configured threshold; the surviving, reachable store must not be marked expired or shut down solely because its local heartbeat client is stuck on the old address. A command that stops a healthy voter can turn a one-node fault into a quorum-loss event.

Code Evidence and Limits

pkg/logservice/service_commands.go calls the managed HAKeeper client's SendLogHeartbeat. In pkg/logservice/hakeeper_client.go, shouldResetHAKeeperClient explicitly excludes context.DeadlineExceeded from resetting the shared client. This is consistent with the observed repeated heartbeat errors and old-address connection; connection-level tracing is still needed to establish every retry path.

Full timelines, negative controls and reproduction details: LogService three-node failure report. Raw logs remain under /home/mo/jxm/logservice-chaos-heartbeat-repeat{,2,3}-20261104/ on the test host.

Searched existing issues for L/shutdown, false LogService heartbeat expiry and this two-stage failure mode; no duplicate found.

Activity

  1. jiangxinmeng1 commented on Nov 4, 2026

    @jiangxinmeng1
    ContributorAuthor

    Follow-up: targeted isolation with the default 5-minute timeout (2026-11-04)

    I repeated the two-stage connection-targeted test on a fresh three-voter cluster with log-store-timeout = "5m". First I isolated HAKeeper leader node0 for 90 seconds and restored it. The new leader was node2; ss showed its HAKeeper client still connected to node1. I then isolated node1 bidirectionally for 390 seconds, while node0 and node2 stayed mutually reachable.

    The node0/node2 logs accumulated 139/102 heartbeat failures by the end of the second stage, but no L/shutdown was generated. With node1 still isolated, node0's client had reconnected to the live node2 and the failure counts stopped increasing. The continuous three-address client finished 2800/2800 Append→Read cycles, with zero retries and a maximum cycle of 3.945 seconds. After network restoration, all three addresses showed the original data and HAKeeper members and identical retained reads.

    This is a negative result for one default-timeout schedule. It does not change the issue's 3/3 positive reproductions under the 30-second accelerated timeout, or establish that all default-timeout network failures are safe. It suggests the time available for heartbeat-client reconnection is material to this failure mode.

    Evidence and exact timings: test report. Raw logs are under /home/mo/jxm/logservice-chaos-quota1-20261104/ on the test host.

  2. added a commit that references this issue on Nov 5, 2026
    d2dab99
  3. XuPeng-SH commented on Nov 5, 2026

    @XuPeng-SH
    Contributor

    QA 交接:#32147 已于 2026-11-05 09:21:42 UTC 合入 main,merge SHA d2dab99。

    本项修复在实际发出的 LogService heartbeat 耗尽 deadline 后释放所选 HAKeeper client generation,由后续心跳重新发现 endpoint;发送前已过期和显式取消不替换共享 generation。完整 issue 评论中的 5 分钟默认阈值阴性对照属于旧版本,不替代合并后的回归。当前没有该合并版本的已验证反例或未完成开发项,本项转 Ariznawlll 验证,不表示验收通过。

    已核对最终 head 4c901ec 的 CI 41992444453:shared build、PROXY/PESSIMISTIC BVT 成功;UT、SCA、UT Coverage 取消,Coverage 跳过,CI Required 失败,不能记为完整 CI 通过。作者报告 focused、owning LogService/driver 与 race 检查通过;本轮未本地实测,原三 voter 网络隔离场景未在合并版本重跑。

    建议保留原两阶段、捕获实际连接的隔离前提:首次 leader 隔离并恢复后,再隔离存活 store 实际连接的 endpoint,保持另外两票互通;核对心跳重发现、存活 store 误过期及 L/shutdown,并覆盖发送前 deadline、显式取消及默认 5 分钟对照。endpoint 仍随机选择,不承诺严格 30 秒最坏恢复上限。

  4. jiangxinmeng1 commented on Nov 6, 2026

    @jiangxinmeng1
    ContributorAuthor

    验证结论(2026-11-06):#32134 描述的“共享 HAKeeper 心跳客户端粘在隔离地址,导致存活 voter 被误关停”机制,在合入 #32147 后的 main(65b721e1b93c6b9e05db2063b220e0c35916b335)上通过现场复测。已阅读本 issue 的全部评论,包括默认 5 分钟阈值的一次阴性对照。

    在 10.222.1.51 新建独立的三 LogService/三 HAKeeper voter 集群,沿用问题复现的 30 秒 log-store-timeout。先隔离当时的 HAKeeper leader node1 90 秒并恢复;三地址重新看到同一三成员视图。随后用 ss -tnp 确认存活 node1 的心跳连接指向 node2(198.18.52.12:57821),再定向隔离 node2 90 秒,node0/node1 保持互通。node1 的旧连接结束并建立新的可用连接;隔离期间三台进程均存活,三份服务日志均无 L/shutdown。网络恢复后三地址的 shard 0/1 成员视图一致。连续 Append→Read 客户端完成 1347/1347 个 cycle。日志保存在测试机 /home/mo/jxm/verify-32133-32135-20261106/(phase1.log、phase2.log、phase2-preconnection.txt、cycle.log 和各 node 的 stdout.log)。

    合入后 main 上的心跳超时、发送前 deadline、显式取消、换 endpoint、旧副本启动及冷 bootstrap 专项测试在普通和 -race 模式均通过。这里验证的是原 30 秒阈值下捕获实际连接的正向复现;评论里的默认 5 分钟、390 秒阴性对照没有重跑。endpoint 仍随机选择,本结果不承诺任意故障时序下严格 30 秒的恢复上限。客户端在隔离期间的一次约 60 秒 Append 重试来自旧版测试客户端,已用合入后源码构建的新客户端另行检查 #32133。

  5. slyunnn commented on Nov 9, 2026

    @slyunnn

    Regression and extended verification for #32134 (2026-11-09)

    Verification Environment

    • Frozen latest remote main at test start, c99234dcf4c94d1ff9d372917cd35041f1a3a682, refactor: integrate temporal index planning with shared owners (refactor: integrate temporal index planning with shared owners #32341).
    • Matching native builds on macOS/arm64 and Linux/amd64, Go 1.27.1. Both binaries reported c99234dcf4. The Linux source archive SHA-256 matched after transfer and GCC 11 was used for its native dependencies.
    • Basic native topology was 2 CN / 1 TN / 1 Log service / Proxy. Proxy 127.0.0.1:6001, CN1 127.0.0.1:16001 and CN2 127.0.0.1:16002 passed actual SQL version/health queries.
    • Failure verification ran over SSH on isolated Linux deployments with 3 LogService/HAKeeper voters, a data shard and direct Go LogService MORPC Append→Read clients. Each process had its own network namespace. SQL endpoints supplied basic topology evidence. Heartbeat acceptance used the real MORPC/network fault scenarios.

    What Was Covered

    • OK — An attempted heartbeat deadline releases the selected shared client generation. A deadline before Send and explicit cancellation preserve that generation. These controlled boundary tests passed normal/race mode and 100 race repetitions each.
    • OK — TestLogHeartbeatMovesOffUnansweredEndpoint exercised a real service and response-dropping TCP proxy. The timed-out client was discarded and the following heartbeat reached a live endpoint. Normal/race mode and 41 adaptive race repetitions passed.
    • OK — Repeated the original 30s two-stage schedule on 2 independent fresh three-voter deployments. Verified HAKeeper and data-shard member views, isolated the first HAKeeper leader for 90 s, restored membership, captured an actual established service-process TCP connection, then isolated its target bidirectionally for another 90 s while the other voters stayed connected.
    • OK — Both 30s trials established a connection to a reachable endpoint while the target remained isolated. All original processes stayed alive, healthy stores were not falsely expired during the targeted window, and no L/shutdown occurred within either accepted run.
    • OK — The first trial completed 25,839 verified Append→Read cycles, 11 Append retries and 0 Read retries, with a maximum cycle of 107432.710 ms. The independent repeat completed 26,533 cycles, 12 Append retries and 0 Read retries, with a maximum cycle of 114067.827 ms. Cycles verify the appended payload at its acknowledged LSN.
    • OK — Re-ran the default 5m timeout control on a fresh isolated deployment. The first leader outage lasted 90 s; the captured connection target was then isolated for 390 s. Connection failover, healthy-store expiry checks, process survival, member recovery and cleanup passed. The client completed 153,606 verified cycles, 1 Append retry and 0 Read retries, with a maximum cycle of 10207.763 ms.
    • OK — The WAL LogService driver consumer package passed. All owned test processes and network namespaces were checked after cleanup. The native SQL topology also shut down cleanly and its owned data was removed.
    • Failed — Broader LogService normal/race package runs failed the independent macOS gossip fixture retry-count assertion, also reproduced with its exact test in isolation. This is tracked in #32392. The heartbeat regressions passed independently.
    • Not covered — A strict 30s worst-case recovery guarantee, every possible partition schedule, and application-level exactly-once behavior after an Append with unknown commit outcome.

    Findings

    PR #32147, merge d2dab994dd87445b5f5d44a06293bd5e09a1eee9, fix(logservice): bound stalled RPCs and stale HAKeeper startup, is an ancestor of the tested main.

    An exhausted deadline after an actual LogService heartbeat attempt replaces the selected client generation, enabling normal endpoint discovery on the next heartbeat. The observed heartbeat path recovered under the captured-connection two-stage faults, including the default-timeout control. Endpoint selection remains randomized.

    MOTR / BVT Coverage

    Reused the maintained heartbeat regressions and the original chaos client/tools, with task-owned orchestration and explicit per-window evidence. A SQL golden cannot exercise a shared HAKeeper client pinned to a partitioned endpoint. No duplicate MOTR case or test commit was added. No MatrixOne service source was changed.

    Each fault schedule was sequential because its second outage depends on the first recovery and a captured connection. Separate scenarios had distinct namespaces, bridges and data directories. Earlier helper compatibility/readiness preparations were excluded from accepted results. Logs reused for later preparation were audited against the accepted run's exact start/end times.

    Large-data regression is not required. The relevant scale is a real three-voter quorum, two-stage network failure and continuous small-record traffic through the expiry window. Additional SQL row volume or a bulk-data TKE job would not improve this heartbeat-generation assertion.

    Final Conclusion

    Fixed on the tested main for the heartbeat-client deadline/failover mechanism and the reproduced false-expiry/shutdown scenario. Both the accelerated 30s regression and default 5m control passed. Broad package validation retains the independent failure tracked by #32392.

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions