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.
This commit is contained in:
Chris Lu
2026-08-01 00:37:22 -07:00
committed by GitHub
parent fa9f471f56
commit de00091765
+2 -1
View File
@@ -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)