mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: verify whether items are sorted in the end of call to mergeTagToMetricIDsRows
This should prevent from inverted index corruption if bug in mergeTagToMetricIDsRows is discovered.
This commit is contained in:
parent
cf4786f34a
commit
c39355921e
1 changed files with 14 additions and 0 deletions
|
@ -2284,9 +2284,23 @@ func mergeTagToMetricIDsRows(data []byte, items [][]byte) ([]byte, [][]byte) {
|
|||
dstData, dstItems = tmm.flushPendingMetricIDs(dstData, dstItems, mpPrev)
|
||||
}
|
||||
putTagToMetricIDsRowsMerger(tmm)
|
||||
assertItemsSorted(dstItems)
|
||||
return dstData, dstItems
|
||||
}
|
||||
|
||||
func assertItemsSorted(items [][]byte) {
|
||||
if len(items) == 0 {
|
||||
return
|
||||
}
|
||||
prevItem := items[0]
|
||||
for _, currItem := range items[1:] {
|
||||
if string(prevItem) > string(currItem) {
|
||||
logger.Panicf("BUG: items aren't sorted: prevItem > currItem\nprevItem=%X\ncurrItem=%X\nitems=%X", prevItem, currItem, items)
|
||||
}
|
||||
prevItem = currItem
|
||||
}
|
||||
}
|
||||
|
||||
// maxMetricIDsPerRow limits the number of metricIDs in tag->metricIDs row.
|
||||
//
|
||||
// This reduces overhead on index and metaindex in lib/mergeset.
|
||||
|
|
Loading…
Reference in a new issue