From 1e4a64844d66413205bb0bf7ee5785b021750365 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 8 Jun 2021 13:04:08 +0300 Subject: [PATCH] lib/storage: properly account the number of loops spent when matching for `or suffixes` This may help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1338 --- lib/storage/index_db.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index 5248bcabbb..8e8341904f 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -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 }