mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01: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
7b1325c3a3
commit
c2927053ee
@ -129,8 +129,8 @@ again:
|
|||||||
if bsr.currItemIdx < len(items) {
|
if bsr.currItemIdx < len(items) {
|
||||||
// An optimization, which allows skipping costly comparison for every merged item in the loop below.
|
// 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
|
// Thanks to @ahfuzhang for the suggestion at https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5651
|
||||||
lastItem := items[len(items)-1].Bytes(data)
|
lastItem := items[len(items)-1].String(data)
|
||||||
compareEveryItem = hasNextItem && string(lastItem) > nextItem
|
compareEveryItem = hasNextItem && lastItem > nextItem
|
||||||
}
|
}
|
||||||
for bsr.currItemIdx < len(items) {
|
for bsr.currItemIdx < len(items) {
|
||||||
item := items[bsr.currItemIdx].Bytes(data)
|
item := items[bsr.currItemIdx].Bytes(data)
|
||||||
@ -183,12 +183,12 @@ func (bsm *blockStreamMerger) flushIB(bsw *blockStreamWriter, ph *partHeader, it
|
|||||||
}
|
}
|
||||||
// Consistency checks after prepareBlock call.
|
// Consistency checks after prepareBlock call.
|
||||||
firstItem := items[0].String(data)
|
firstItem := items[0].String(data)
|
||||||
if firstItem != string(bsm.firstItem) {
|
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)
|
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)
|
lastItem := items[len(items)-1].String(data)
|
||||||
if lastItem != string(bsm.lastItem) {
|
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)
|
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
|
// 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.
|
// can be expensive check in prod for items with long common prefix.
|
||||||
|
Loading…
Reference in New Issue
Block a user