mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/mergeset: properly record the firstItem in metaindexRow at blockStreamWriter.WriteBlock
The 3c246cdf00
added an optimization where the previous metaindexRow
could be saved to disk when the current block header couldn't be added indexBlock because the resulting
indexBlock size became too big. This could result in an empty metaindexRow.firstItem for the next metaindexRow.
This commit is contained in:
parent
2eb967231b
commit
5d69ba630e
1 changed files with 5 additions and 5 deletions
|
@ -130,11 +130,6 @@ func (bsw *blockStreamWriter) MustClose() {
|
|||
func (bsw *blockStreamWriter) WriteBlock(ib *inmemoryBlock) {
|
||||
bsw.bh.firstItem, bsw.bh.commonPrefix, bsw.bh.itemsCount, bsw.bh.marshalType = ib.MarshalSortedData(&bsw.sb, bsw.bh.firstItem[:0], bsw.bh.commonPrefix[:0], bsw.compressLevel)
|
||||
|
||||
if !bsw.mrFirstItemCaught {
|
||||
bsw.mr.firstItem = append(bsw.mr.firstItem[:0], bsw.bh.firstItem...)
|
||||
bsw.mrFirstItemCaught = true
|
||||
}
|
||||
|
||||
// Write itemsData
|
||||
fs.MustWriteData(bsw.itemsWriter, bsw.sb.itemsData)
|
||||
bsw.bh.itemsBlockSize = uint32(len(bsw.sb.itemsData))
|
||||
|
@ -155,6 +150,11 @@ func (bsw *blockStreamWriter) WriteBlock(ib *inmemoryBlock) {
|
|||
bsw.flushIndexData()
|
||||
bsw.unpackedIndexBlockBuf = bsw.bh.Marshal(bsw.unpackedIndexBlockBuf)
|
||||
}
|
||||
|
||||
if !bsw.mrFirstItemCaught {
|
||||
bsw.mr.firstItem = append(bsw.mr.firstItem[:0], bsw.bh.firstItem...)
|
||||
bsw.mrFirstItemCaught = true
|
||||
}
|
||||
bsw.bh.Reset()
|
||||
bsw.mr.blockHeadersCount++
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue