mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
lib/mergeset: verify that the index block for in-memory part doesnt exceed the 3*maxIndexBlockSize
This commit is contained in:
parent
9a3a88b321
commit
1c3eac5c1e
1 changed files with 5 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/encoding"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/encoding"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/fs"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/fs"
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type inmemoryPart struct {
|
type inmemoryPart struct {
|
||||||
|
@ -84,6 +85,10 @@ func (mp *inmemoryPart) Init(ib *inmemoryBlock) {
|
||||||
|
|
||||||
bb := inmemoryPartBytePool.Get()
|
bb := inmemoryPartBytePool.Get()
|
||||||
bb.B = mp.bh.Marshal(bb.B[:0])
|
bb.B = mp.bh.Marshal(bb.B[:0])
|
||||||
|
if len(bb.B) > 3*maxIndexBlockSize {
|
||||||
|
// marshaled blockHeader can exceed indexBlockSize when firstItem and commonPrefix sizes are close to indexBlockSize
|
||||||
|
logger.Panicf("BUG: too big index block: %d bytes; mustn't exceed %d bytes", len(bb.B), 3*maxIndexBlockSize)
|
||||||
|
}
|
||||||
mp.indexData.B = encoding.CompressZSTDLevel(mp.indexData.B[:0], bb.B, compressLevel)
|
mp.indexData.B = encoding.CompressZSTDLevel(mp.indexData.B[:0], bb.B, compressLevel)
|
||||||
|
|
||||||
mp.mr.firstItem = append(mp.mr.firstItem[:0], mp.bh.firstItem...)
|
mp.mr.firstItem = append(mp.mr.firstItem[:0], mp.bh.firstItem...)
|
||||||
|
|
Loading…
Reference in a new issue