mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 07:19:17 +01:00
lib/mergeset: retain the buffer with the data used by indexBlock.bhs, inside indexBlock.buf
Previously indexBlock.bhs pointed to the buffer, which could be changed over time.
This could result in incorrect time series search over time.
This is a follow-up for 58b40f514c
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3343
This commit is contained in:
parent
454060fd78
commit
06300fe9b8
@ -136,6 +136,9 @@ func (p *part) MustClose() {
|
||||
|
||||
type indexBlock struct {
|
||||
bhs []blockHeader
|
||||
|
||||
// The buffer for holding the data referrred by bhs
|
||||
buf []byte
|
||||
}
|
||||
|
||||
func (idxb *indexBlock) SizeBytes() int {
|
||||
|
@ -285,8 +285,10 @@ func (ps *partSearch) readIndexBlock(mr *metaindexRow) (*indexBlock, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot decompress index block: %w", err)
|
||||
}
|
||||
idxb := &indexBlock{}
|
||||
idxb.bhs, err = unmarshalBlockHeadersNoCopy(idxb.bhs[:0], ps.indexBuf, int(mr.blockHeadersCount))
|
||||
idxb := &indexBlock{
|
||||
buf: append([]byte{}, ps.indexBuf...),
|
||||
}
|
||||
idxb.bhs, err = unmarshalBlockHeadersNoCopy(idxb.bhs[:0], idxb.buf, int(mr.blockHeadersCount))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot unmarshal block headers from index block (offset=%d, size=%d): %w", mr.indexBlockOffset, mr.indexBlockSize, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user