fix(storage): 修复 WAL.Clear() nil panic 并添加并发安全保护#31
Conversation
- Clear() 在 WAL 禁用模式(file==nil)时使用 config.G.WALPath 避免空指针 - 为 WAL 添加 sync.Mutex 保护所有公共方法(Write/Read/Close/Sync/Clear) - Read() 中使用 io.ReadFull 确保完整读取,消除部分数据风险 - RaftWAL.LoadLogs() 使用 io.ReadFull 修复截断读取 - 统一使用 slog 格式,移除冗余的 [ERROR]/[WARN] 前缀 - 重命名 HEADER_LENGTH→headerLength(非导出标识符)
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR hardens WAL (write-ahead log) reliability across two layers. The core ChangesWAL Reliability and Thread-Safety
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary by CodeRabbit
Bug Fixes
Refactor