mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/mergeset: make sure that the first and the last items are in the original range after prepareBlock()
Previously the checks were to strict by requiring to leave the same first and last items by prepareBlock() Thanks to @ahfuzhang for the suggestion at https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5655
This commit is contained in:
parent
2adb38a9c4
commit
1c5163ae51
1 changed files with 6 additions and 6 deletions
|
@ -129,8 +129,8 @@ again:
|
|||
if bsr.currItemIdx < len(items) {
|
||||
// An optimization, which allows skipping costly comparison for every merged item in the loop below.
|
||||
// Thanks to @ahfuzhang for the suggestion at https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5651
|
||||
lastItem := items[len(items)-1].Bytes(data)
|
||||
compareEveryItem = hasNextItem && string(lastItem) > nextItem
|
||||
lastItem := items[len(items)-1].String(data)
|
||||
compareEveryItem = hasNextItem && lastItem > nextItem
|
||||
}
|
||||
for bsr.currItemIdx < len(items) {
|
||||
item := items[bsr.currItemIdx].Bytes(data)
|
||||
|
@ -183,12 +183,12 @@ func (bsm *blockStreamMerger) flushIB(bsw *blockStreamWriter, ph *partHeader, it
|
|||
}
|
||||
// Consistency checks after prepareBlock call.
|
||||
firstItem := items[0].String(data)
|
||||
if firstItem != string(bsm.firstItem) {
|
||||
logger.Panicf("BUG: prepareBlock must return first item equal to the original first item;\ngot\n%X\nwant\n%X", firstItem, bsm.firstItem)
|
||||
if firstItem < string(bsm.firstItem) {
|
||||
logger.Panicf("BUG: prepareBlock must return the first item bigger or equal to the original first item;\ngot\n%X\nwant\n%X", firstItem, bsm.firstItem)
|
||||
}
|
||||
lastItem := items[len(items)-1].String(data)
|
||||
if lastItem != string(bsm.lastItem) {
|
||||
logger.Panicf("BUG: prepareBlock must return last item equal to the original last item;\ngot\n%X\nwant\n%X", lastItem, bsm.lastItem)
|
||||
if lastItem > string(bsm.lastItem) {
|
||||
logger.Panicf("BUG: prepareBlock must return the last item smaller or equal to the original last item;\ngot\n%X\nwant\n%X", lastItem, bsm.lastItem)
|
||||
}
|
||||
// Verify whether the bsm.ib.items are sorted only in tests, since this
|
||||
// can be expensive check in prod for items with long common prefix.
|
||||
|
|
Loading…
Reference in a new issue