test(storage): the record's header is not written ahead of the synced store

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-30 03:42:37 -08:00
1 parent 5b95b66f8d
commit 38077535e7
1 file changed
+18
@@ -314,3 +314,21 @@ func TestCompleteRecordPagePositions(t *testing.T) {
t.Fatalf("page fields: %+v", p)
}
}
// A write assigned but not synced is not durable: pages written through it
// are ahead of the synced store, and the header is refused.
func TestRecordHeaderIsNotWrittenAheadOfTheSyncedStore(t *testing.T) {
s, path := newMappedCheckpointStoreV3(t)
writeSynced(t, s, 1, 2)
if _, err := s.Write(3, blk(3)); err != nil { // assigned, not synced
t.Fatal(err)
}
dir := chunkRecordDir(path)
chunks := recordPagesAt(t, s, dir, s.NextLSN()-1)
if err := completeChunkRecord(s, dir, 7, chunks); err == nil {
t.Fatal("a header was written through a write that is not durable")
}
if _, err := os.Stat(filepath.Join(dir, chunkRecordHeaderName)); !errors.Is(err, os.ErrNotExist) {
t.Fatalf("header exists ahead of the synced store: %v", err)
}
}