mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/storage: simplify the fix from 488940502c
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3566
This commit is contained in:
parent
f739e44802
commit
eb9a542c1f
1 changed files with 6 additions and 13 deletions
|
@ -852,6 +852,7 @@ func (is *indexSearch) searchLabelNamesWithFiltersOnDate(qt *querytracer.Tracer,
|
||||||
mp := &is.mp
|
mp := &is.mp
|
||||||
dmis := is.db.s.getDeletedMetricIDs()
|
dmis := is.db.s.getDeletedMetricIDs()
|
||||||
loopsPaceLimiter := 0
|
loopsPaceLimiter := 0
|
||||||
|
underscoreNameSeen := false
|
||||||
nsPrefixExpected := byte(nsPrefixDateTagToMetricIDs)
|
nsPrefixExpected := byte(nsPrefixDateTagToMetricIDs)
|
||||||
if date == 0 {
|
if date == 0 {
|
||||||
nsPrefixExpected = nsPrefixTagToMetricIDs
|
nsPrefixExpected = nsPrefixTagToMetricIDs
|
||||||
|
@ -878,9 +879,9 @@ func (is *indexSearch) searchLabelNamesWithFiltersOnDate(qt *querytracer.Tracer,
|
||||||
}
|
}
|
||||||
labelName := mp.Tag.Key
|
labelName := mp.Tag.Key
|
||||||
if len(labelName) == 0 {
|
if len(labelName) == 0 {
|
||||||
labelName = []byte("__name__")
|
underscoreNameSeen = true
|
||||||
}
|
}
|
||||||
if isArtificialTagKey(labelName) {
|
if isArtificialTagKey(labelName) || string(labelName) == string(prevLabelName) {
|
||||||
// Search for the next tag key.
|
// Search for the next tag key.
|
||||||
// The last char in kb.B must be tagSeparatorChar.
|
// The last char in kb.B must be tagSeparatorChar.
|
||||||
// Just increment it in order to jump to the next tag key.
|
// Just increment it in order to jump to the next tag key.
|
||||||
|
@ -895,20 +896,12 @@ func (is *indexSearch) searchLabelNamesWithFiltersOnDate(qt *querytracer.Tracer,
|
||||||
ts.Seek(kb.B)
|
ts.Seek(kb.B)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if string(labelName) == string(prevLabelName) {
|
|
||||||
var tagValue []byte
|
|
||||||
if string(labelName) != "__name__" {
|
|
||||||
tagValue = labelName
|
|
||||||
}
|
|
||||||
kb.B = is.marshalCommonPrefixForDate(kb.B[:0], date)
|
|
||||||
kb.B = marshalTagValue(kb.B, tagValue)
|
|
||||||
kb.B[len(kb.B)-1]++
|
|
||||||
ts.Seek(kb.B)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
lns[string(labelName)] = struct{}{}
|
lns[string(labelName)] = struct{}{}
|
||||||
prevLabelName = append(prevLabelName[:0], labelName...)
|
prevLabelName = append(prevLabelName[:0], labelName...)
|
||||||
}
|
}
|
||||||
|
if underscoreNameSeen {
|
||||||
|
lns["__name__"] = struct{}{}
|
||||||
|
}
|
||||||
if err := ts.Error(); err != nil {
|
if err := ts.Error(); err != nil {
|
||||||
return fmt.Errorf("error during search for prefix %q: %w", prefix, err)
|
return fmt.Errorf("error during search for prefix %q: %w", prefix, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue