mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-17 04:36:50 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user