Skip to content

[Bug]: TN WAL replay fails after 3m on one unresponsive LogService replica despite two healthy voters #32235

Closed

Description

@jiangxinmeng1

Description

A TN WAL driver starting ReplayForWrite can fail after 3 minutes while two of the three LogService voters remain responsive. Its first GetTruncatedLsn uses a pooled RPC connection to one unresponsive follower. The managed client changes addresses only after the RPC returns an error; the driver's first-attempt deadline is its entire 3-minute retry budget. When that deadline expires, the driver stops instead of trying another already available replica, so WAL replay returns context deadline exceeded before reading any records.

This is an observed WAL driver startup failure, not an end-to-end TN/SQL outage claim. TAE's replay/promotion path uses this driver and propagates replay errors, making TN recovery a credible impact. A real TN process was not started in this test.

Environment

  • MatrixOne source baseline upstream/main at d61a7206c16b30baa4efc525eb6067c4364035aa; probe/report commit f77bb91fd7.
  • Dedicated three-voter LogService cluster on 10.222.1.51; data shard 1, RPC addresses 127.0.0.1:58201, :58211, :58221; default 5-minute store expiration.
  • Test uses TN's wal.NewLogserviceHandle and StoreImpl.Replay(ReplayForWrite), the real logservice.NewClient with all three service addresses, and default ClientMaxCount=100 / driver MaxTimeout=3m. The probe's outer replay context is 6 minutes so it does not cause the 3-minute failure.

Stable reproduction

On a fresh dedicated cluster with the checked-in WAL probe and chaos-client, run the reproducer using a unique tag. It starts the WAL process, waits until its 100 client connections have been created, queries the current data-shard leader, SIGSTOPs one ordinary replica, and releases ReplayForWrite. It retries connection-selection attempts until the replay call is stalled, then keeps only that one replica paused through the driver's default deadline. A safety task and finally resume the node.

python3 test/logservice-chaos/tn_driver_probe/reproduce_replay_tail.py \
  --root /home/mo/jxm/logservice-tnwal-lifecycle-20261105 \
  --probe /home/mo/jxm/tn-wal-probe-lifecycle \
  --tag replay-tail-new

While replay is stalled, query GetTruncatedLsn directly through each of the other two addresses. In both fault runs those requests immediately returned 3612; their shard status also showed a leader and all three configured voters. A healthy control replay after node recovery completed in 229.536 ms.

Run Paused ordinary replica First GetTruncatedLsn ReplayForWrite
replay-tail-1 node0 context deadline exceeded after 3m0.000644s, retry-times=1 Exit 2; zero WAL records read/applied.
replay-tail-9 node2 context deadline exceeded after 3m0.000224s, retry-times=1 Exit 2; zero WAL records read/applied.

Code path and expected behavior

  • logservicedriver/replayer.go:initReadWatermarks calls getTruncatedPSNFromBackend before any replay reads.
  • logservicedriver/truncate.go:getTruncatedPSNFromBackend obtains one pooled client. Each GetTruncatedLsn attempt uses d.config.MaxTimeout (default 3 minutes); after the first failure it checks whether elapsed time already exceeds that same budget, and returns the error without trying another client.
  • pkg/logservice/client.go creates data RPC clients with WithBackendReadTimeout(0) and resets a managed client's connection only after the request returns an error. A TCP connection to a stopped/unresponsive replica can therefore consume the whole driver budget.
  • TAE db.ReplayWal invokes Wal.Replay; ReplayCtl.StopForWrite propagates replay failure to promotion. The test proves failure at the WAL boundary; TN process and SQL effects remain unmeasured.

With two responsive voters and a readable truncate watermark, replay should switch to a reachable replica within a bounded failover window and continue. Any timeout/failover change must preserve WAL read consistency and avoid treating an uncertain write outcome as a definite failure.

Related #32133 and #32148 cover 60-second Append/Read tails from stale RPC connections. This issue records a distinct 3-minute replay initialization failure caused by the GetTruncatedLsn retry budget.

Full report. Raw logs are retained on 51 under /home/mo/jxm/logservice-tnwal-lifecycle-20261105/replay-tail-{1,9}.log and replay-tail-control.log. All three test nodes were stopped after the experiment.

Activity

  1. self-assigned this
    on Nov 5, 2026
  2. jiangxinmeng1 commented on Nov 5, 2026

    @jiangxinmeng1
    ContributorAuthor

    同一旧连接失效机制还影响 checkpoint 后台物理 Truncate:在默认 100-client TN WAL driver 上,checkpoint intent ACK 已返回,后台新建的 LogService 客户端连接到普通副本 node2。暂停 node2,另外两票保持可读,直接查询截断位点立即返回旧值 PSN 3612。首次截断尝试的默认 3 分钟 context 到期后,第二次才换地址成功;Wal-Truncate-Execute 总耗时 3m0.529s,物理位点随后推进到 PSN 6923。期间测试进程已经输出写入完成摘要,但正常 Close 一直等待后台截断。测试屏障放在第一次 RPC 发送前,计入首次尝试的 context 时间;没有将 3 分钟归因于 RPC 本身的全部耗时。

    这不是新的回放失败,也未测量事务提交延迟;它是两票可用时相同长超时机制在物理清理路径的表现。记录与探针:jiangxinmeng1@081adbc931 ,原始日志在 51 的 /home/mo/jxm/logservice-tnwal-lifecycle-20261105/truncate-tail-a.log。

  3. jiangxinmeng1 commented on Nov 5, 2026

    @jiangxinmeng1
    ContributorAuthor

    补充真实 TN WAL driver 入口(wal.NewLogserviceHandle、默认 100 client、三地址)的网络故障复现:先建立客户端池,再把一个普通副本的专用 RPC 端口用 iptables OUTPUT DROP 黑洞,另两票始终存活且直接 GetTruncatedLsn / GetLatestLsn 成功。

    两次命中旧连接的 ReplayForWrite 都在首次 GetTruncatedLsn 等待约 152.15 秒后收到 TCP i/o timeout,重连并成功回放;完整耗时 152.154 / 152.119 秒。健康对照耗时 280.795 毫秒。两次回放的 10 条保留 WAL 记录与对照逐条一致。与此前 SIGSTOP 单副本后约 180 秒直接回放失败不同,网络 DROP 最终成功,但两者都显示两票可用时故障检测长尾。

    报告及安全清理的复现脚本:https://github.com/jiangxinmeng1/matrixone/blob/7914370688/docs/design/logservice_three_node_failure_test.md ,https://github.com/jiangxinmeng1/matrixone/blob/7914370688/test/logservice-chaos/tn_driver_probe/reproduce_replay_network.py 。原始日志在 51 的 /home/mo/jxm/logservice-tnwal-lifecycle-20261105/replay-net-4.log、replay-net2-2.log、replay-net-control.log。测试节点与网络规则均已清理。

  4. added a commit that references this issue on Nov 6, 2026
    ee5e93b
  5. XuPeng-SH commented on Nov 6, 2026

    @XuPeng-SH
    Contributor

    QA 交接:#32149 已于 2026-11-06 07:40:26 UTC 合入 main,merge ee5e93bcefd4f04bcda6b8e5002eef96038396d3,最终 head f83150eb8ffb17a3d91a3fbf6865e5a0d0b9ec2e。将本 issue 的 replay 初始化截断水位读取修复转交 @Ariznawlll 验证,不代表验收通过,也不把所有 WAL 路径一并标为已修复。

    修复范围:GetTruncatedLsn 单次 7 秒 child deadline,响应黑洞或连接错误后 reset,在 caller 有效时重连重试;getTruncatedPSNFromBackend 获取 client 后使用一个总 MaxTimeout budget,并让重试/backoff 响应取消。空池 clientPool.Get() 仍不识别 context;不改变 Append/Truncate 写语义。

    已完整读正文与 2 条评论、PR 最终 diff 和讨论。旧构建的 SIGSTOP 约 180 秒失败、网络 DROP 约 152 秒后恢复、10 条 WAL 数据一致均是修复前证据,不是新版本失败。作者报告真实 LogService client+response-dropping proxy 的水位恢复及短 caller 截止、mock transient retry/取消测试,以及 logservice/WAL normal/race、focused repeats、vet 通过。最新本地验证及 approved review 绑定旧 head 790bca9921;Mergify 报告合并门禁 CI Required 成功。本轮没有本地或集群实测,三 voter 网络场景尚未在合并版本重跑。

    QA 建议:建立默认 100-client 池后,对命中的普通副本分别 SIGSTOP/网络黑洞,保持另外两票可读,验证 replay 初始化换地址恢复、总预算/短 caller 取消、保留 LSN/payload 与健康对照一致;另测随机重连、健康慢请求及空池边界。7 秒不是完整 TN/SQL 或所有 blocked-send 的硬时限。

    范围边界:现有评论中的 checkpoint 物理 Truncate / Close 长尾不作为本次 replay 初始化修复的通过结论。#32329 跟踪后台 Truncate 不响应 shutdown 的取消链,#32322 跟踪 replay Read 外层取消,均未被本 PR 修复,继续保留研发;#32133 的 Dragonboat proposal transport 也不包含。本次转测不关闭这些独立问题。

  6. Ariznawlll commented on Nov 10, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。验收范围是 #32149 修复的 WAL replay 初始化读取截断位点:单个 LogService 副本无响应时,在另外两个副本可用的前提下重连并继续回放。此结论不扩展到完整 TN 重启、SQL 可用性或其他 WAL 写入/截断路径。

    关键证据

    • 2026-11-10 在官方 main 11d2e1ef7e1b3ed3a20e6d7f29f912e55118db5b 上编译同一版本的 MO 和真实 WAL driver;隔离环境启动 3 个 LogService voter,使用默认 100-client 连接池。健康对照回放成功。
    • 网络黑洞:9 次尝试中 2 次实际命中故障副本,命中时分别约 7.046、7.040 秒完成回放;9/9 次的 10 条已确认记录的 LSN 与内容完全一致,另两票的直接读取均成功。
    • 暂停副本(SIGSTOP):3 次尝试中 2 次实际命中,分别约 7.047、7.038 秒完成回放;3/3 次的 10 条记录与写入确认一致,另外两票直接读取成功。上述时长是本环境观测值,不是所有网络和 TN 路径的硬性上限。
    • 黑盒故障注入和实际数据比对:夜间回归运行;持续回归已提交 mo-nightly-regression PR #1916,当前 PR 检查通过,待合入后按 main 每日运行。
    • 白盒边界:空连接池 race 测试 重复 10 次,验证空池等待在 caller 截止后仍需等连接归还,随后才返回 deadline 错误,与研发交接描述一致。

    待解决点

    空连接池 Get() 仍不响应 context,属于本次修复明确排除的边界,不能将本次通过理解为其已修复。物理 Truncate/Close、replay Read 的取消链及端到端 TN/SQL 故障恢复不在本次验收范围;相关问题继续分别跟踪。

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