lib/storage: properly account the number of loops spent when matching for or suffixes

This may help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1338
This commit is contained in:
Aliaksandr Valialkin 2021-06-08 13:04:08 +03:00
parent 2c6b917749
commit 1e4a64844d

View file

@ -2579,10 +2579,10 @@ func (is *indexSearch) updateMetricIDsForOrSuffixesNoFilter(tf *tagFilter, metri
kb.B = append(kb.B, orSuffix...)
kb.B = append(kb.B, tagSeparatorChar)
lc, err := is.updateMetricIDsForOrSuffixNoFilter(kb.B, metricIDs, maxMetrics, maxLoopsCount-loopsCount)
loopsCount += lc
if err != nil {
return loopsCount, err
}
loopsCount += lc
if metricIDs.Len() >= maxMetrics {
return loopsCount, nil
}
@ -2600,10 +2600,10 @@ func (is *indexSearch) updateMetricIDsForOrSuffixesWithFilter(tf *tagFilter, met
kb.B = append(kb.B, orSuffix...)
kb.B = append(kb.B, tagSeparatorChar)
lc, err := is.updateMetricIDsForOrSuffixWithFilter(kb.B, metricIDs, sortedFilter, tf.isNegative, maxLoopsCount-loopsCount)
loopsCount += lc
if err != nil {
return loopsCount, err
}
loopsCount += lc
}
return loopsCount, nil
}