Repository navigation
Description
Description
A LogService follower can retain an invalid exported snapshot directory after a process crash between Dragonboat's rename of a completed snapshot into its final directory and removal of dragonboat.snapshot.message. On restart, LogService ignores the directory while loading its snapshot manager, but Dragonboat rejects subsequent exports at the same index. A quiescent shard repeatedly logs request export snapshot failed: request rejected until its applied index advances.
Environment
- MatrixOne binary built from
d61a7206c16b30baa4efc525eb6067c4364035aa(upstream/mainat the time of the test). - Three voter LogService shard and HAKeeper cluster on
[email protected], isolated network namespaces, default 5-minute log store timeout. node1 is a follower with replica ID262146; node0 and node2 remain alive and mutually reachable. - Test data and logs:
/home/mo/jxm/logservice-chaos-boundary-20261104/. No TN/CN was started.
Reproduction
- Start all three stores with their original directories. Write records and truncate enough to allow node1 to export a new snapshot.
- Watch node1's
exported-snapshot/shard-1/replica-262146/parent directory for a final snapshot directoryIN_MOVED_TOevent. The exact watcher used issnapshot-crash-watch.pyin the test directory; it sendsSIGKILLto node1'smo-serviceimmediately when Dragonboat renamessnapshot-<index>-262146.generatingtosnapshot-<index>. - Inspect the final directory before restarting node1. Restart node1 with its original data directory; leave node0 and node2 running. Keep the shard quiescent and observe node1's export attempts and the directory contents.
- For a control, kill node1 on creation of the
*.generatingdirectory instead, then restart and observe whether export resumes.
The final-directory crash was repeated at indices 453 (snapshot-00000000000001C5) and 569 (snapshot-0000000000000239). Both attempts left three files in the final directory: snapshot-<index>.gbsnap, snapshot.metadata, and dragonboat.snapshot.message. In both restarts the directory stayed on disk and same-index export was repeatedly rejected: 26 attempts in about 29 seconds and 18 attempts in about 20 seconds, respectively. These are 2/2 attempts at the targeted rename window, not a claim about random crash frequency.
The control killed node1 when snapshot-00000000000001C2-262146.generating (index 450) was created. It left an empty temporary directory; restart cleaned it and successfully exported index 450. The previously tested empty final directory was manually injected and has not been produced by a normal process crash.
Actual and Expected Result
Actual: The three-file final directory is invalid for LogService's snapshotItem.Valid, which requires exactly two files. snapshotManager.Init silently ignores the failure to load it. Dragonboat sees the same final directory on the next export and rejects the request. While no new records are applied, node1 keeps failing export attempts and logging errors. After 100 new appends advanced the applied index, node1 exported later indices; the invalid directory remained on disk.
Expected: Restart should reconcile or safely discard an incomplete exported snapshot, and the next export should make progress without requiring unrelated business writes. It should not silently keep an untracked final directory that prevents same-index retry.
Observed Impact and Limits
- The other two voters stayed online. All three addresses returned the original three-member view after restart.
- The 100 acknowledged appends were read identically from all three addresses and matched by LSN and payload.
Truncate(500)succeeded; node1 imported a later snapshot at index 459, and 54 retained acknowledged records still matched across all three addresses. - No data loss or failure of this later truncate was observed. Long-term WAL/disk growth on an indefinitely quiescent shard was not measured.
Code Evidence
- Dragonboat
internal/server/snapshotenv.go:FinalizeSnapshotcreates a flag file in the temporary directory, checks whether the final directory already exists, then renames the temporary directory to the final name.snapshotter.Commitremoves the flag only after finalization. - MatrixOne
pkg/logservice/snapshot.go:snapshotItem.Validrequireslen(names) == 2;snapshotManager.Initdiscards errors fromsnapshots.addwhen scanning existing export directories. - MatrixOne
pkg/logservice/truncation.go:exportSnapshotcallsSyncRequestSnapshotand only adds the snapshot to the manager after success.
Detailed steps, timings, and evidence: LogService failure test report. The test cluster is stopped, and both on-disk invalid directories and logs are retained on the test host.
Activity
jiangxinmeng1 commentedon Nov 4, 2026
Follow-up: data leader crash reproduces the final-directory residue (2026-11-04)
I repeated the final-directory rename-window
SIGKILLagainst the data shard leader, rather than a follower, in a fresh cluster withmax-exported-snapshot=1. HAKeeper had a different leader and the other two voters remained healthy. At export index 157, the killed leader's final directory again containedsnapshot-<index>.gbsnap,snapshot.metadata, anddragonboat.snapshot.message. On restart the flag-bearing directory remained. Continuous writes advanced the applied index and allowed a later export at index 426; the old invalid directory remained on disk.Two-voter
Truncate(150)succeeded during the outage, and a separate survivor-only client completed 100/100 Append→Read cycles with no retries. After restart, all three addresses agreed on the original member set and retained data; laterTruncate(426)succeeded. This confirms the residue mechanism also applies to a leader. It does not show permanent write unavailability or data loss.During the same recovery, two
SyncRequestSnapshotcalls timed out yet later produced two-file final directories at indices 400 and 414. Those directories remained after the registered index-426 snapshot was imported, and were cleaned only after another restart scanned and imported index 414. This is an additional observation from one recovery window; I have not established sustained accumulation or filed it as a separate defect.Details and retained evidence: test report and
/home/mo/jxm/logservice-chaos-snapshot-leader-20261104/on the test host.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,最终 headf83150eb8ffb17a3d91a3fbf6865e5a0d0b9ec2e。转交 @Ariznawlll 验证,不表示验收通过。修复范围:启动保留的数据副本前,仅清理规范 final snapshot 目录中仍含
dragonboat.snapshot.message的中断导出。完整无 marker 的导出与临时目录保留,目录读取/删除错误显式阻止启动。此 PR 同时包含 #32161 的运行期迟完成快照调和,因此现有评论提及的超时后完成导出应按该范围另核。已读完整正文、现有 1 条评论、PR 最终 diff 与讨论。原报告的 follower/leader rename-window SIGKILL 残留来自修复前构建,不能当作合并后反例。作者报告定向 snapshot 回归、normal/race 和 vet 通过;最新具体本地验证及 approved review 绑定旧 head
790bca9921,最终 diff 中的真实文件系统、重复清理、失败删除保留和启动测试不等于本轮重新运行。Mergify 报告合并门禁CI Required成功。本轮没有本地或集群实测。QA 建议:分别覆盖 follower/leader 在 final rename 后、marker 删除前崩溃,同一 index 无新增业务写入即可重新导出;校验完整导出及临时目录不误删、重复重启幂等、I/O/删除失败可见且证据保留,并对保留 LSN/payload 做读回。迟完成导出按 #32161 核验后续 tick 的 import/quota 调和,允许 tick 间短时超额,不宣称任意损坏目录均可清理、长期磁盘界限或无数据丢失已获验收。
Ariznawlll commentedon Nov 11, 2026
测试版本
官方 main:
553e16f52b02d59e9ecc5e3c8862f2603e661f48。本地独立三进程、三副本 LogService;Linux CI 使用相同 main SHA。原问题验证
本地监听最终目录生成,在仍有
dragonboat.snapshot.message的真实窗口 SIGKILL follower,使用原数据目录重启;无需业务写入推动,原索引可重新导出,标记被清理。最新 main 实测通过,前一 SHA 真实窗口 3/3 通过。Happy Path 覆盖
正常导出及重启后重新导出成功;保留的 24 条已确认记录从三个副本均可读取。
Unhappy Path 覆盖
真实窗口分别对 follower 和 leader 注入崩溃:最新 main 均通过,前一 SHA 各 3/3 通过。leader 重选后索引从 37 推进到 38,重导出成功;follower 保持原索引 37 重导出成功。
白盒验证
快照目录有效性、初始化及恢复相关 Go 测试通过;最新 main 的重点测试以
-race -count=3通过。回归测试
已加入 MOTR 回归 PR #1926,PR 尚未合入。Linux 每日回归在已完成的真实快照目录中构造残留标记后重启,验证清理和重新导出;该构造场景并非 Linux 上命中真实崩溃窗口,本地另完成上述真实窗口测试。
测试证据
Linux CI 三副本任务 follower/leader 两种场景通过,均验证
marker_removed=true、24 条保留记录和三个副本可读。测试结论
测试通过。