lib/mergeset: properly reset bsr.bhIdx after the call to blockStreamReader.readNextBHS()

The issue has been introduced in 58b40f514c

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3343
This commit is contained in:
Aliaksandr Valialkin 2022-11-16 21:21:46 +02:00
parent c3362e3db4
commit a75137c1c2
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1
2 changed files with 3 additions and 2 deletions

View File

@ -167,7 +167,7 @@ func unmarshalBlockHeadersNoCopy(dst []blockHeader, src []byte, blockHeadersCoun
for i := 0; i < blockHeadersCount; i++ {
tail, err := dst[dstLen+i].UnmarshalNoCopy(src)
if err != nil {
return dst, fmt.Errorf("cannot unmarshal block header: %w", err)
return dst, fmt.Errorf("cannot unmarshal block header #%d out of %d: %w", i, blockHeadersCount, err)
}
src = tail
}

View File

@ -297,8 +297,9 @@ func (bsr *blockStreamReader) readNextBHS() error {
// Unmarshal the unpacked index block into bsr.bhs.
bsr.bhs, err = unmarshalBlockHeadersNoCopy(bsr.bhs[:0], bsr.unpackedBuf, int(mr.blockHeadersCount))
if err != nil {
return fmt.Errorf("cannot unmarshal blockHeader #%d in the index block #%d: %w", len(bsr.bhs), bsr.mrIdx, err)
return fmt.Errorf("cannot unmarshal blockHeaders in the index block #%d: %w", bsr.mrIdx, err)
}
bsr.bhIdx = 0
return nil
}