From 40c4e1ac8ef8ea48e565bcee6e59102f52b7e466 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 30 Nov 2026 10:25:53 -0800 Subject: [PATCH] test(storage): a page changed at open holds the header's G Co-Authored-By: Claude Opus 5.5 --- .../core/storage/chunk_record_runtime_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/seaweed-block/core/storage/chunk_record_runtime_test.go b/seaweed-block/core/storage/chunk_record_runtime_test.go index 6af2d0da6b..8760e3a30b 100644 --- a/seaweed-block/core/storage/chunk_record_runtime_test.go +++ b/seaweed-block/core/storage/chunk_record_runtime_test.go @@ -391,3 +391,21 @@ func TestRecordRuntimeCopiesItsInputs(t *testing.T) { t.Fatal("the caller's slice changed the runtime's state without the kernel") } } + +// A page whose chunks were judged changed at open is not current on disk: G +// does not pass it until it is written again. +func TestRecordRuntimeAPageChangedAtOpenHoldsG(t *testing.T) { + pos := uint64(20) + kinds := []chunkkernel.Kind{chunkkernel.Unknown, chunkkernel.Absent} // disk said HP for chunk 0 + r, err := newChunkRecordRuntime(filepath.Join(t.TempDir(), "rec"), 2, 7, func() uint64 { return pos }, + kinds, make([][32]byte, 2), []uint64{10}, 10) + if err != nil { + t.Fatal(err) + } + if err := r.WriteDue(time.Now()); err != nil { + t.Fatal(err) + } + if h, err := readChunkRecordHeader(r.dir); err == nil && h.G > 10 { + t.Fatalf("header G %d passed a page changed at open and not yet written (valid through 10)", h.G) + } +}