mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: simplify the fix from 488940502c
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3566
This commit is contained in:
parent
488940502c
commit
41e00a0df7
1 changed files with 6 additions and 13 deletions
|
@ -829,6 +829,7 @@ func (is *indexSearch) searchLabelNamesWithFiltersOnDate(qt *querytracer.Tracer,
|
|||
mp := &is.mp
|
||||
dmis := is.db.s.getDeletedMetricIDs()
|
||||
loopsPaceLimiter := 0
|
||||
underscoreNameSeen := false
|
||||
nsPrefixExpected := byte(nsPrefixDateTagToMetricIDs)
|
||||
if date == 0 {
|
||||
nsPrefixExpected = nsPrefixTagToMetricIDs
|
||||
|
@ -855,9 +856,9 @@ func (is *indexSearch) searchLabelNamesWithFiltersOnDate(qt *querytracer.Tracer,
|
|||
}
|
||||
labelName := mp.Tag.Key
|
||||
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.
|
||||
// The last char in kb.B must be tagSeparatorChar.
|
||||
// Just increment it in order to jump to the next tag key.
|
||||
|
@ -872,20 +873,12 @@ func (is *indexSearch) searchLabelNamesWithFiltersOnDate(qt *querytracer.Tracer,
|
|||
ts.Seek(kb.B)
|
||||
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{}{}
|
||||
prevLabelName = append(prevLabelName[:0], labelName...)
|
||||
}
|
||||
if underscoreNameSeen {
|
||||
lns["__name__"] = struct{}{}
|
||||
}
|
||||
if err := ts.Error(); err != nil {
|
||||
return fmt.Errorf("error during search for prefix %q: %w", prefix, err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue