diff --git a/tsdb/engine/tsm1/encoding.go b/tsdb/engine/tsm1/encoding.go index ce685aa2fa..482335d369 100644 --- a/tsdb/engine/tsm1/encoding.go +++ b/tsdb/engine/tsm1/encoding.go @@ -625,13 +625,13 @@ func DecodeStringBlock(block []byte, tdec *TimeDecoder, vdec *StringDecoder, a * func packBlock(buf []byte, typ byte, ts []byte, values []byte) []byte { // We encode the length of the timestamp block using a variable byte encoding. // This allows small byte slices to take up 1 byte while larger ones use 2 or more. - sz := 1 + 10 + len(ts) + len(values) + sz := 1 + binary.MaxVarintLen64 + len(ts) + len(values) if cap(buf) < sz { buf = make([]byte, sz) } b := buf[:sz] b[0] = typ - i := binary.PutUvarint(b[1:10], uint64(len(ts))) + i := binary.PutUvarint(b[1:1+binary.MaxVarintLen64], uint64(len(ts))) i += 1 // block is , ,