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) + } +}