From de000917657c49b022b9f7806c6907628e4706bb Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 1 Aug 2026 00:37:22 -0700 Subject: [PATCH] test: random needles always carry at least one byte (#10523) A zero-data needle lands in .dat as a size-0 record, byte-identical to a delete marker, so scans that walk .dat count it as deleted. Once in 1024 writes newRandomNeedle produced one, and the idx-head repair then skipped a row TestRepairIdxHeadTombstones_ReadOnlyVolume expected back. --- weed/storage/volume_vacuum_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weed/storage/volume_vacuum_test.go b/weed/storage/volume_vacuum_test.go index 764528e5a..5dd990a42 100644 --- a/weed/storage/volume_vacuum_test.go +++ b/weed/storage/volume_vacuum_test.go @@ -397,7 +397,8 @@ type needleInfo struct { func newRandomNeedle(id uint64) *needle.Needle { n := new(needle.Needle) - n.Data = make([]byte, rand.Intn(1024)) + // never zero bytes: an empty needle writes a size-0 .dat record, indistinguishable from a delete marker + n.Data = make([]byte, 1+rand.Intn(1023)) rand.Read(n.Data) n.Checksum = needle.NewCRC(n.Data)