3.2 WAL:明确 write-stopped 后 pending/aborted entry 生命周期 #2

Closed
opened 2026-06-09 10:31:52 +08:00 by dailz · 0 comments
Owner

背景

第 3.2 节规定 WAL write / fsync failure 后,失败 batch 不发布,sequence 不复用,引擎进入 write-stopped 状态。第 3.3 节规定 flush 只刷 sequence <= publishedSequence 且非 aborted 的 entry。

问题

文档尚未明确 write-stopped 后 pending / unpublished / aborted entry 的完整生命周期。

需要明确的问题包括:

  • 进入 write-stopped 后是否允许 MemTable freeze / flush
  • 含 pending / aborted entry 的 MemTable 是否能参与 checkpoint 推进
  • 关闭时这些 entry 如何处理
  • 后台 flush 与 MANIFEST 推进是否必须避开这些 entry

风险

如果规则不明确,后续实现可能把失败写入错误刷入 SSTable,或错误推进 checkpoint / MANIFEST,导致恢复路径认为失败 batch 已经持久化。

建议

补充规则:

  • 进入 write-stopped 后,后台 flush 只能刷已发布 entry
  • 含 unpublished / aborted entry 的 MemTable 不得作为 checkpoint 推进依据
  • pending / aborted entry 只作为运行期内部状态存在,关闭后随内存丢弃
  • recovery 只从完整、CRC 合法、sequence 连续的 WAL batch 恢复已发布数据

参考

  • docs/design.md:117 WAL write failure 处理
  • docs/design.md:119 fsync unknown 处理
  • docs/design.md:588 Flush 过滤规则
## 背景 第 3.2 节规定 WAL write / fsync failure 后,失败 batch 不发布,sequence 不复用,引擎进入 write-stopped 状态。第 3.3 节规定 flush 只刷 `sequence <= publishedSequence` 且非 aborted 的 entry。 ## 问题 文档尚未明确 write-stopped 后 pending / unpublished / aborted entry 的完整生命周期。 需要明确的问题包括: - 进入 write-stopped 后是否允许 MemTable freeze / flush - 含 pending / aborted entry 的 MemTable 是否能参与 checkpoint 推进 - 关闭时这些 entry 如何处理 - 后台 flush 与 MANIFEST 推进是否必须避开这些 entry ## 风险 如果规则不明确,后续实现可能把失败写入错误刷入 SSTable,或错误推进 checkpoint / MANIFEST,导致恢复路径认为失败 batch 已经持久化。 ## 建议 补充规则: - 进入 write-stopped 后,后台 flush 只能刷已发布 entry - 含 unpublished / aborted entry 的 MemTable 不得作为 checkpoint 推进依据 - pending / aborted entry 只作为运行期内部状态存在,关闭后随内存丢弃 - recovery 只从完整、CRC 合法、sequence 连续的 WAL batch 恢复已发布数据 ## 参考 - `docs/design.md:117` WAL write failure 处理 - `docs/design.md:119` fsync unknown 处理 - `docs/design.md:588` Flush 过滤规则
dailz closed this issue 2026-06-09 11:39:14 +08:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dailz/go-kv#2