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
2b8358726f
commit
95e3d648cb
1 changed files with 14 additions and 0 deletions
|
@ -2355,9 +2355,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