fix: address Final Verification Wave findings

- Sync() now flushes BlockWriter before fd.Sync() for durability
- Pre-validate encoding before sequence allocation (design doc compliance)
- Remove dead _ = rec assignment in recover.go
- Remove unused maxPayload field from SegmentWriter
- Handle Put error in MemTable.Publish with panic on invariant violation
This commit is contained in:
dailz
2026-06-12 14:29:53 +08:00
parent 5905dbc06f
commit b833a21848
5 changed files with 100 additions and 10 deletions
+6 -1
View File
@@ -2,6 +2,7 @@ package memtable
import (
"errors"
"fmt"
"sync"
"sync/atomic"
)
@@ -114,7 +115,11 @@ func (mt *MemTable) Publish(upToSequence uint64) {
// Re-put each entry as published. Each call acquires the skiplist mutex.
for _, e := range toPublish {
_ = mt.skiplist.Put(e.key, e.value, e.sequence, false)
if err := mt.skiplist.Put(e.key, e.value, e.sequence, false); err != nil {
// Reserve guaranteed space, so this should never happen.
// If it does, it's an internal invariant violation.
panic(fmt.Sprintf("memtable: Put failed after Reserve: %v", err))
}
}
// Update high-water mark after all entries are visible.