Repository navigation
Description
Description
When an exported Raft snapshot finishes after SyncRequestSnapshot has timed out, Dragonboat can leave a valid final snapshot directory on disk, but LogService's snapshotManager never registers it. Subsequent normal imports remove only registered snapshots, so this directory remains on disk while the process keeps running. Two controlled pause/resume injections reproduced this 2/2 times on a three-voter test cluster; after later imports, both orphan directories remained and the on-disk final snapshot count exceeded the configured quota.
This is a process-pause/snapshot-completion timing fault using valid Append, Read, and Truncate calls. No snapshot files were manually created or edited.
Environment and preconditions
- Dedicated LogService cluster on
10.222.1.51, three data voters, node3 data replica477185. Test bundlelogservice-chaos-20261103-d61a7206. - Node3
truncate-interval=1s,max-exported-snapshot=4. Other two voters stay alive while node3 is paused for 5 seconds, less than this test cluster's 30-second store-expiry threshold. - Normal Append→Read load continues.
Truncatetargets are within LSNs already acknowledged and verified by the client: 11665, 11800, 11950, and 12150.
Stable reproduction
- Start the checked-in pause watcher on the dedicated test host. It verifies the process executable, watches node3's data-shard exported-snapshot directory using
inotify, and sendsSIGSTOPas soon as a newsnapshot-*.generatingdirectory is created. It sendsSIGCONTafter five seconds in afinallyblock. - While it watches, advance
Truncateto an already verified LSN to free exported-snapshot quota and run the direct client's normalcycleAppend→Read load. Wait for the watcher's pause/resume and the load to finish. - Verify the exported request logged
request export snapshot failed: timeout, no matchingexport snapshot successexists for its index, and a final directory containing exactly.gbsnapandsnapshot.metadatanevertheless appeared. - Advance
Truncatebeyond that index using another already verified LSN. Verify node3 logs a successful import of a newer snapshot, while the timed-out final directory remains. Repeat once with a new index.
Concrete results:
| Injection | Snapshot that timed out but became a final directory | Later successful import | Directory after import |
|---|---|---|---|
| First pause at 17:02:03 | 11697; export timeout at 17:02:08.764 | 11785 after Truncate(11800) |
Still present |
| Second pause at 17:04:02 | 11993; export timeout at 17:04:07.264 | 12048 after Truncate(12150) |
Both 11697 and 11993 still present |
Node3 ended with 7 final exported snapshot directories despite max-exported-snapshot=4; at least the two named directories were created by these timed-out exports. The 300/300 and 200/200 normal Append→Read loads completed without retries. After final truncation to 12150, all three single-address reads had identical SHA256 d3aa32f0ee28946f1815bdbc0fbbf35ace81f077569f0c80242261ef43609042; the 42 retained acknowledged records from the second load matched by LSN/payload, with no duplicate payload in the retained range. No WAL loss or final client error was observed.
Expected behavior
A successfully completed exported snapshot should be registered or reclaimed even if the request caller has already timed out. The running store should not retain valid but untracked final snapshot directories through later imports, and the configured export quota should also bound the on-disk completed snapshots during repeated timeouts.
Code path and impact
pkg/logservice/truncation.go:217exportSnapshotreturns immediately onSyncRequestSnapshoterror. It callssnapshotMgr.Addonly after a success response.pkg/logservice/snapshot.gosnapshotManager.Removetraverses the in-memory registered list; it has no path to remove a completed directory that was never added.snapshotManager.Initdoes scan on replica startup, so this report does not claim the directory survives restart.- Repeated timeout/late-completion windows can accumulate completed directories while the process stays online, bypassing the intended on-disk quota and using extra disk. Snapshot sizes in this small test were tiny; production disk impact was not measured.
This differs from #32144: that issue concerns an invalid final directory containing Dragonboat's extra marker file after a crash, blocking same-index retry. Here both directories are valid two-file snapshots, but timed-out exports were never registered and later normal imports did not clean them.
Test report has the full timeline. Raw evidence on 51 is under /home/mo/jxm/logservice-chaos-20261103-d61a7206: pause-snapshot-round{1,2}.log, late-export-pause{,2}-20261104.load, late-export-pause2-20261104.node{1,2,3}.read, node3 stdout.log, and the two snapshot directories.
Activity
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 验证,不代表验收通过。修复范围:snapshot 请求 timeout/canceled 或导出后 Add 失败时,记录该 replica 的不确定导出;此后每次 truncation tick 从磁盘登记完整两文件 final snapshot,并在 import/quota 决策前调和。超 quota 优先删除最新快照,保留最老 import candidate;扫描错误保留旧视图并重试。未受影响副本不扫描,不将尚有 marker 的运行期目录当成完整导出删除。
已读完整正文,当前 0 条评论;最终 diff 与 PR 讨论已核对。旧构建 2/2 pause/resume 后遗留有效快照的复现是修复前证据,没有本次合并版本反例。作者报告真实 Dragonboat post-admission timeout/迟完成回归、quota/scanner-error 对照、完整 logservice normal/race、focused repeats 与 vet 通过;最新本地验证和 approved review 明确绑定旧 head
790bca9921。Mergify 报告合并门禁CI Required成功。本轮仅核对记录,未运行本地或集群测试。QA 建议:重现 admission 后 pause/timeout/恢复,先让一次 scan 早于最终目录出现,再验证后续 tick 无需重启就登记、import、清理;重复超时下核对磁盘 quota、保留最老 import candidate 和 retained LSN/payload。覆盖 quota=0、小 quota、文件尚未完整、marker 随后消失、扫描/删除失败重试及正常副本不额外扫描。该实现允许 tick 间短时 quota 超额,受影响副本会持续扫描,不应写成任何瞬间的硬磁盘上限、长期磁盘性能或数据安全已全部验收。
Ariznawlll commentedon Nov 11, 2026
测试版本
官方 main:
553e16f52b02d59e9ecc5e3c8862f2603e661f48。本地独立三进程、三副本 LogService;Linux CI 使用相同 main SHA。原问题验证
在生成快照目录出现时暂停 follower 5 秒,观察到导出请求超时,但快照最终完成;随后推进截断,确认迟到的最终目录被纳入管理、被后续导入并清理。最新 main 实测通过;此前 SHA
45917e803f2915f6f0838b2b2fe9f591fc5b6018独立重复 3/3 通过。Happy Path 覆盖
正常写入、截断、导出和导入完成;保留的 30 条已确认记录从三个副本读取一致。
Unhappy Path 覆盖
覆盖导出完成晚于调用超时、恢复后继续截断及清理;本地最终目录数为 1。此结果是最终收敛结果,不表示任何瞬间都严格不超过配额。
白盒验证
超时后对迟到快照重新扫描和配额相关 Go 测试通过,最新 main 的相关测试以
-race -count=3通过;零配额边界另在前一 SHA 执行 race 3 次通过。回归测试
已加入 MOTR 回归 PR #1926,包含真实三进程超时注入,PR 尚未合入。
测试证据
Linux CI 三副本任务 通过,记录了
export_timeout=true、imported_and_removed=true和retained=30。测试结论
测试通过。