diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index bc959f1135..544777646e 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -2744,10 +2744,9 @@ func (is *indexSearch) getMetricIDsForDateTagFilter(tf *tagFilter, date uint64, // Use global search if date isn't set. kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixTagToMetricIDs) } - kb.B = append(kb.B, tf.prefix[len(commonPrefix):]...) tfNew := *tf tfNew.isNegative = false // isNegative for the original tf is handled by the caller. - tfNew.prefix = kb.B + tfNew.prefix = append(kb.B, tf.prefix[len(commonPrefix):]...) metricIDs, loopsCount, err := is.getMetricIDsForTagFilter(&tfNew, maxMetrics, maxLoopsCount) if err != nil { return nil, loopsCount, err @@ -2760,6 +2759,7 @@ func (is *indexSearch) getMetricIDsForDateTagFilter(tf *tagFilter, date uint64, // This fixes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1601 // See also https://github.com/VictoriaMetrics/VictoriaMetrics/issues/395 maxLoopsCount -= loopsCount + tfNew = tagFilter{} if err := tfNew.Init(kb.B, tf.key, []byte(".+"), false, true); err != nil { logger.Panicf(`BUG: cannot init tag filter: {%q=~".+"}: %s`, tf.key, err) }