Repository navigation
Description
Description
A LogService Read on an established connection to a network-isolated store can wait for the full one-minute per-attempt timeout even when the other two voters remain healthy and can serve the same record. The TN WAL read loop retries only after that attempt returns. This causes a long recovery/read tail during a single-store network fault.
This is the Read path. Related #32133 documents the same client-visible one-minute tail for Append. The two paths share connection management but have different callers and retry semantics, so this issue tracks the Read behavior and its replay impact separately.
Environment
- MatrixOne LogService binary from
d61a7206c16b30baa4efc525eb6067c4364035aa(upstream/mainat test creation). - Three-voter data shard and HAKeeper shard on the isolated
10.222.1.51test host. Default 5-minute log-store timeout. One store's test veth is disconnected bidirectionally; the other two stores remain online and mutually reachable. - Direct test client uses the same
logservice.NewClientAPI and MO WAL's default one-minute per-attempt timeout and three-minute retry-continuation window. No TN/CN process was started, so SQL/TN end-to-end latency is not claimed.
Controlled Reproduction
- Start the three-voter cluster and create one LogService client with all three RPC addresses. Append a uniquely tagged record and wait for its successful LSN response.
- Pause that same client immediately before it issues
Read(acknowledgedLSN). Confirm its established TCP peer withss -tnp; the test helper has-pause-read-seq,-read-ready-file, and-read-release-fileswitches for this exact boundary. - Disconnect the connected store's test veth while keeping the other two voters mutually reachable. Release the paused Read. Observe its first attempt, retry and final record/payload match. Restore the isolated store afterward.
With the production-equivalent one-minute attempt timeout, the Read of acknowledged LSN 949 returned context deadline exceeded after 60,000.428 ms, then the next attempt read the record successfully. The Read phase took 60,291.560 ms. The cycle's overall elapsed time includes an intentional pause and is not the failure latency. The connected target was node2 198.18.51.12:57121; the other two stores retained a data-shard leader and could answer shard queries during the wait.
An earlier naturally timed data-leader crash also produced a Read of already acknowledged LSN 158 that waited 60,000.820 ms and returned EOF; its retry succeeded. During that outage, a separate client connected only to the surviving two stores completed 100/100 Append→Read cycles without retries (maximum cycle 0.550 seconds), and Truncate(150) succeeded.
Fast-Retry Control
Using the same pause/isolate/release procedure, but setting the test client's per-attempt timeout to two seconds:
| Isolated established peer | First Read failure | Read phase through successful retry |
|---|---|---|
node0 198.18.51.10:57101 |
2,000.734 ms, context deadline exceeded |
3,204.537 ms |
node2 198.18.51.12:57121 |
2,000.961 ms, context deadline exceeded |
3,330.323 ms |
Both records were verified by LSN and payload on the second Read. A healthy-network control with the two-second setting finished 150/150 Append→Read cycles with zero retries and a maximum cycle of 638.310 ms. After network restoration, three single-address reads matched and contained all three controlled records at LSNs 789, 945, and 949. This does not establish that two seconds is an appropriate production timeout across workloads; it demonstrates that the long tail is governed by the per-attempt timeout in this failure mode.
Current Code Path and Expected Behavior
pkg/logservice/service.gohandleReaddispatches tostore.queryLog; it does not handle client reconnection.pkg/logservice/client.gomanagedClient.Readresets the client after an RPC error, but internally retries only shard-not-found errors.EOFand deadline errors return to the caller. The data client creates MORPC withWithBackendReadTimeout(0).pkg/vm/engine/tae/logstore/driver/logservicedriver/driver.goreadFromBackendwraps each attempt withDefaultOneTryTimeout = 1mand retries after failure and backoff; its default three-minute continuation window is checked after an attempt, not a strict wall-clock cap.
Waiting a minute is therefore consistent with current code when the established connection is blackholed and no earlier TCP/RPC error arrives. A client serving WAL replay should bound time spent on a stale connected address while preserving correct Read results after reconnecting. The appropriate timeout/failover policy needs production latency and false-timeout evaluation; this issue does not propose a two-second global default.
Evidence
- Test report and reusable pause hook.
- Raw logs on the test host:
/home/mo/jxm/logservice-chaos-snapshot-leader-20261104/fast-read-{2s,2s-b,60s}.load,fast-read-baseline.load, andfast-read-final.node{0,1,2}.read. - All test processes and test network namespaces were stopped after verification; files remain available.
Activity
jiangxinmeng1 commentedon Nov 5, 2026
补充 TN WAL 回放入口的证据(默认
ClientMaxCount=100,没有启动完整 TN):在GetTruncatedLsn已成功、首次 replayRead尚未发出时暂停它已连接的普通副本,保持另外两票运行。两次命中的独立 WAL 进程回放分别耗时 61.102s、60.810s;Wal-Replay-Info.read-duration为 1m0.603s、1m0.338s。超时后换地址,回放成功,5 条保留的 LSN/payload 与健康对照逐条一致。故障期间另两票的最新 LSN 查询立即成功,driver 后台每 5 秒轮询截断位点也持续成功。副本若在客户端池创建前就已暂停,健康地址回放只需 121.560ms,说明触发条件是已建立的旧连接。这是本 issue 已记录的同一 Read 旧连接长尾,不另建重复缺陷。探针和复现脚本见 jiangxinmeng1@081adbc931 ,原始日志保留于 51 的
/home/mo/jxm/logservice-tnwal-lifecycle-20261105/read-tail-6.log、read-tail2-10.log、replay-cold-pool-follower-down.log。没有完整 TN/SQL 延迟测量。fix(logservice): harden reads, proposals, snapshots, truncation, and …
XuPeng-SH commentedon Nov 6, 2026
QA 交接:#32149 已于 2026-11-06 07:40:26 UTC 合入 main,merge
ee5e93bcefd4f04bcda6b8e5002eef96038396d3(最终 PR headf83150eb8ffb17a3d91a3fbf6865e5a0d0b9ec2e)。本项转交 @Ariznawlll 验证,不代表验收通过。修复范围:LogService
Read每次调用增加 7 秒 child deadline;已建立连接无响应或发生相应 MORPC 连接错误后,清理连接,在原 caller context 仍有效时重试同一 LSN。使用已合入的 #32147 底层连接读取窗口;Append 的未知提交结果语义不改变。证据:已完整核对本 issue 正文及现有 1 条评论、PR 最终 diff 与讨论。原先 60 秒 Read / 60–61 秒 WAL replay 报告是修复前证据,没有本次合并版本的已验证反例。作者报告 response-dropping proxy 定向 Read 回归、包级 normal/race 和 vet 通过;正文最新本地验证及 approved review 绑定旧 head
790bca9921,不能写成最终 head 的重新实测。Mergify 在合并时报告CI Required成功。此次只核对远端证据,未运行本地或集群测试。QA 建议:复现“建立连接后隔离当前普通副本、其余两票健康”及 leader 失效,验证相同已确认 LSN/payload 的恢复、短 caller 取消、健康对照与 >7 秒慢请求误重试影响。三副本网络故障场景尚未在该合并版本重跑;7 秒不是完整 WAL/SQL 延迟保证,blocked send、空 client pool、随机重连及整体 Read 重试取消需分别观察。#32322 的 WAL Read 外层取消问题、#32133 的 proposal transport 和 #32329 的 shutdown Truncate 重试属于独立未修范围,不纳入本次 Read 修复验收。
Ariznawlll commentedon Nov 6, 2026
结论
补充 #32149 合入后的实测:本轮限定的 LogService 组件场景中,已建立连接不返回业务响应时,
Read能约 7 秒后切换到另一副本并读回完整 ACK;没有重现原先等到调用方长超时的现象。这不是完整 TN/WAL/SQL 恢复验收,也不代表其他重试路径已经修复。关键证据
ee5e93bcefd4f04bcda6b8e5002eef96038396d3,Go 1.27.1、darwin/arm64;生产源码未修改,仅通过临时测试 overlay 扩展场景。Read/GetTruncatedLsn的超时、主动取消、故障地址仍在候选集,以及 64KiB 普通/压缩响应只传前六字节后断连等对照,共 36 个子用例完成。200ms caller deadline 约 200ms 返回,主动取消约 1ms;之后 ACK 与截断水位一致。另有 13 个独立三副本恢复代次完成 3→2→3、失去多数派与恢复核账;测试脚本没有给 Read 添加外层重试。日志为
readfix-three-replica-response-fault3-corrected.log、readfix-final-controls3.log、readfix-three-log-strict3-corrected.log、readfix-three-log-strict10.log,保留在本次隔离目录/private/tmp/mo-logservice-20261106-wLWbwx/。最初的消息上限/压缩配置错误与临时探针编译错误均单独留存,不计作产品缺陷或通过记录。待解决点
本轮是单进程嵌入式服务、真实 RPC/Raft、StrictMem 和受控客户端响应路径故障;不是物理多机网络隔离、磁盘掉电或完整 TN/SQL 冷启动。自然调度的 13 轮未再次捕获旧 ReadIndex 慢样本,不能声称竞态穷尽。WAL 外层忽略取消的 #32322 已另外补充证据,不纳入本项读取修复结论;7 秒也不是完整 SQL 恢复时延保证。
Ariznawlll commentedon Nov 11, 2026
测试版本
官方 main
553e16f52b02d59e9ecc5e3c8862f2603e661f48;本地及 Linux CI 使用独立三进程、三副本 LogService。原问题验证
建立三地址客户端连接后,分别让当前连接的 leader 或 follower 不返回响应,其他两票保持健康。
Read自动切换并读回已确认记录,Linux CI 两种角色约 7.00–7.04 秒,不再占满原报告的 60 秒调用方预算。故障通过代理丢弃响应实现,不等同物理断网。Happy Path 覆盖
故障前后写入、读取正常;恢复后从三个副本核对确认过的 LSN 和内容。每种故障角色在本地三进程矩阵均重复 3 次通过。
Unhappy Path 覆盖
覆盖既有连接不可用、leader/follower 两类目标;此前白盒组件对照覆盖调用方短 deadline、主动取消、仅业务响应丢失及部分响应断开。读取调用本身没有由测试脚本添加外层重试。
白盒验证
前述受控组件用例及 race 对照通过;最新 main 的相关连接故障回归以三进程直接 API 复测,结果与该组件证据一致。
回归测试
已加入 MOTR PR #1926 的每日三副本回归,PR 尚未合入。
测试证据
Linux CI 三副本任务 使用上述 main SHA,两种角色均记录
operation=read和all_voters_read=pass;最新提交的 Linux 三副本 CI 也已通过。测试结论
测试通过。这里的 7 秒是该受控 LogService client 场景的观测值,不是完整 SQL 恢复 SLA。