mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
lib/storage: harden the check that the original items are sorted after mergeTagToMetricIDsRows fails to preserve sort order
This commit is contained in:
parent
2abd5154e0
commit
f6334bffa1
@ -2289,7 +2289,17 @@ func mergeTagToMetricIDsRows(data []byte, items [][]byte) ([]byte, [][]byte) {
|
||||
if err := checkItemsSorted(dstItems); err != nil {
|
||||
logger.Errorf("please report this error at https://github.com/VictoriaMetrics/VictoriaMetrics/issues : %s", err)
|
||||
dstData = append(dstData[:0], tmm.dataCopy...)
|
||||
dstItems = append(dstItems[:0], tmm.itemsCopy...)
|
||||
dstItems = dstItems[:0]
|
||||
// tmm.itemsCopy can point to overwritten data, so it must be updated
|
||||
// to point to real data from tmm.dataCopy.
|
||||
buf := dstData
|
||||
for _, item := range tmm.itemsCopy {
|
||||
dstItems = append(dstItems, buf[:len(item)])
|
||||
buf = buf[len(item):]
|
||||
}
|
||||
if err := checkItemsSorted(dstItems); err != nil {
|
||||
logger.Panicf("BUG: the original items weren't sorted: %s", err)
|
||||
}
|
||||
}
|
||||
putTagToMetricIDsRowsMerger(tmm)
|
||||
return dstData, dstItems
|
||||
|
Loading…
Reference in New Issue
Block a user