Repository navigation
Description
Description
The TN WAL driver's background physical Truncate crashes the whole process if its fresh LogService client cannot be created for the default five-minute retry window. Existing pooled connections may still be healthy: concurrent WAL Appends and checkpoint intents completed in both reproductions while only new TCP connections to the three LogService RPC ports were blocked.
clientPool.GetOnFly() returns (nil, err) for an ordinary connection failure. truncateFromRemote handles only ErrClientPoolClosed; it then registers defer client.Putback() and calls client.wrapped.Truncate with a nil client. The resulting panic is unhandled in the background queue goroutine.
Environment
- Baseline
upstream/mainatd61a7206c16b30baa4efc525eb6067c4364035aa; full test report. - Dedicated three-voter LogService data shard 1 on 10.222.1.51, RPC addresses
127.0.0.1:58201/58211/58221, with three running nodes and separate disks. - A test process uses the TN's real
wal.NewLogserviceHandle,ReplayForWrite,AppendEntry(GroupUserTxn), andRangeCheckpoint(1,end,files...), default 100-client pool and retry settings. No TN/CN service or SQL workload was started.
Reproduction
- Start the concurrent WAL probe with
-start-ready-fileand-start-release-file,-checkpoint-every-acks 100 -checkpoint-lag 50 -checkpoint-files(run A). Wait for the ready file; its real driver has finished replay and initialized its client pool.ssconfirmed established TCP sessions to all three RPC ports. - On the isolated test host, insert
iptables -I OUTPUT -p tcp -d 127.0.0.1 -m multiport --dports 58201,58211,58221 --tcp-flags SYN,RST,ACK SYN -j DROP. This blocks only fresh TCP connections to the test RPC ports. Release the probe; maintain the rule for over five minutes, then remove it. - The existing sessions successfully acknowledge all 320 user writes and checkpoint intents at user LSN 62, 181, and 270. Background
Wal-Truncate-Prepareselects physical PSN 211. Fresh-client creation logsrpc timeoutuntil the five-minute retry window ends, then the process panics. - Remove the rule and start a new WAL probe on the same three nodes. It replays the prior 320 records. Repeat with 160 writes, checkpoint intents at user LSN 363 and 440, and the same SYN-only rule (run B). It crashes at the same stack after another five minutes.
| Run | Acknowledged operations | Last failure | Panic |
|---|---|---|---|
| A | 320/320 writes, 3 checkpoint intents | Wal-Truncate-Execute after 5m0.633s: rpc timeout |
truncateFromRemote:178, deferred (*wrappedClient).Putback(0x0) |
| B | 160/160 writes, 2 checkpoint intents | Wal-Truncate-Execute after 5m0.632s: rpc timeout |
Same stack |
Both runs had truncated=0 after the crash. The three LogService replicas stayed up. After removing the rule, a no-fault control on the same disks completed 160/160 additional writes, two checkpoints, physical truncation to PSN 954, and a subsequent independent ReplayForWrite succeeded (ready lsn=640 checkpointed=600). This test observed a TN WAL process crash, not WAL data loss or a real TN SQL failure.
Code path and expected behavior
clientPool.GetOnFlyreturns nil on failedNewClient.truncateFromRemotereturns only forErrClientPoolClosed; an ordinary error reaches the nil dereference.- TN's client factory uses a fresh
logservice.NewClientand the configured connection timeout. A completed checkpoint can therefore trigger this path even while existing pool connections can write.
Expected: return every client-creation error from truncateFromRemote to doTruncate, report the failed physical truncation, and allow a later retry. A network connection failure must not terminate TN.
Raw logs are retained on 51 under /home/mo/jxm/logservice-newconn-failure-20261105/: probe.log, probe-b.log, control.log, replay-check.log, and three node logs.
Activity
Fix LogService required LSN and WAL recovery across failover (#32330)
XuPeng-SH commentedon Nov 10, 2026
QA 交接:修复 PR #32330 已于 2026-11-10 12:26:03 UTC 合入 main,merge SHA
39e470bad8262405906ada3b38d5da40647184f9(最终 headb837dd5d2d5ba8015b64aa037cde13b00621a7bf)。本项转交 QA,不代表验收通过。truncateFromRemote 对所有新建 client 错误直接返回,避免 nil client 解引用,并安排受关闭控制的后续截断重试;重点复测只阻断新 TCP SYN 而旧连接仍可 Append、工厂失败后恢复重试和独立 replay,不以局部 WAL 测试宣称完整 TN SQL 已验证。
已核对本 issue 完整讨论及 PR 最终相关源码、全部 review/回复:旧快照 revision、ownership loss 重启、生产工厂取消、leader-state RPC deadline、read-only TruncateWAL 五项旧问题均已有修复及后续评审确认,没有当前适用的已验证反例或未完开发 follow-up 阻止本项转测。
实际证据与限制:作者报告 logservice、datasync、tnservice、TAE db、logservicedriver、wal owning suites 及定向 ownership/cancellation race 通过;远端合并队列记录 CI Required 成功。以上为作者/远端证据,本轮未本地执行、未读取测试主机原始日志,不能替代最终 merge SHA 的真实三 voter 故障、完整 TN/CN SQL 或长稳验收。请按本项原场景复测并记录版本、注入边界、时延及恢复结果。旧格式已物理截断且无认证 checkpoint 边界的 #32240 仍单独保留研发;不因本次转测自动要求 4.2 backport。
Ariznawlll commentedon Nov 11, 2026
测试版本
官方 main:
553e16f52b02d59e9ecc5e3c8862f2603e661f48的 Linux 三副本回归;本地故障专项另使用前一 main SHA45917e803f2915f6f0838b2b2fe9f591fc5b6018。原问题验证
使用真实 TN WAL driver,在后台 checkpoint 触发物理截断时让新客户端创建失败超过默认五分钟重试窗口,同时保持已有池连接可用;重试耗尽后进程存活,没有出现空客户端解引用 panic。恢复新连接后物理截断推进到 PSN 114。
Happy Path 覆盖
故障期间连续执行 33 次写入及一次额外写入,均由已有连接确认;故障解除后截断恢复,独立 WAL driver 重放 44 条保留记录,内容无重复。
Unhappy Path 覆盖
最新 main 的 Linux 回归使用不可达地址持续 330 秒,验证重试耗尽后存活和恢复重放。本地前一 SHA 另使用 TCP 静默代理使新连接超时 330 秒、既有连接直连继续工作,重试耗尽及重放均通过。该代理模拟新连接不可用;没有使用原报告的内核 iptables SYN DROP,也没有运行完整 TN/CN SQL 工作负载。
白盒验证
TestTruncateOnFlyClientFactoryErrorCanRetry和关闭时取消客户端创建相关测试在最新 main 上以-race -count=3通过。回归测试
已加入 MOTR 回归 PR #1926,包含 330 秒新客户端创建失败、继续写入、故障解除后的截断及重放校验;PR 尚未合入。
测试证据
Linux CI 三副本任务 在上述 main SHA 上通过,日志记录
replay_retained=44 duplicate=0。本地静默代理测试也记录 330 秒期间已有连接持续写入、恢复后remote_truncation_recovered=114和 44 条记录无重复。测试结论
测试通过。