[Important] 尾部截断后缺少持久化步骤 #12
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
来源
Oracle 审核
docs/design.mdSection 3.2 WAL位置
Section 3.2 "Physical Record 解析规则" 尾部损坏处理(~line 495)
问题描述
Recovery 允许截断最后一个 segment 的尾部损坏。但截断操作本身(
ftruncate+ 删除后续空 segment)需要 fsync 才能在再次崩溃时保持一致性。设计文档未说明截断后的持久化步骤。如果在截断后、fsync 前再次崩溃,recovery 会再次看到未截断的尾部损坏,可能重复截断或产生其他不一致。
建议修复
在 "恢复完成状态" 之后或 "Recovery 扫描流程" 末尾添加截断持久化步骤:
ftruncateactive segment 到lastCompleteBatchEndfsynctruncated segmentstartSequence == expectedSequence但无 complete batch 的后续空 segmentfsyncWAL directoryfsyncmetadata directory以上完成后,引擎才能开始接受新写入。