mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
app/vmstorage/transport: simplify setupTfss in order to prevent the possibility of nil tfs
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/534
This commit is contained in:
parent
e4cef1b678
commit
01719f4949
1 changed files with 2 additions and 7 deletions
|
@ -874,19 +874,14 @@ var (
|
||||||
func (ctx *vmselectRequestCtx) setupTfss() error {
|
func (ctx *vmselectRequestCtx) setupTfss() error {
|
||||||
tfss := ctx.tfss[:0]
|
tfss := ctx.tfss[:0]
|
||||||
for _, tagFilters := range ctx.sq.TagFilterss {
|
for _, tagFilters := range ctx.sq.TagFilterss {
|
||||||
if len(tfss) < cap(tfss) {
|
tfs := storage.NewTagFilters(ctx.sq.AccountID, ctx.sq.ProjectID)
|
||||||
tfss = tfss[:len(tfss)+1]
|
|
||||||
} else {
|
|
||||||
tfss = append(tfss, &storage.TagFilters{})
|
|
||||||
}
|
|
||||||
tfs := tfss[len(tfss)-1]
|
|
||||||
tfs.Reset(ctx.sq.AccountID, ctx.sq.ProjectID)
|
|
||||||
for i := range tagFilters {
|
for i := range tagFilters {
|
||||||
tf := &tagFilters[i]
|
tf := &tagFilters[i]
|
||||||
if err := tfs.Add(tf.Key, tf.Value, tf.IsNegative, tf.IsRegexp); err != nil {
|
if err := tfs.Add(tf.Key, tf.Value, tf.IsNegative, tf.IsRegexp); err != nil {
|
||||||
return fmt.Errorf("cannot parse tag filter %s: %s", tf, err)
|
return fmt.Errorf("cannot parse tag filter %s: %s", tf, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tfss = append(tfss, tfs)
|
||||||
tfss = append(tfss, tfs.Finalize()...)
|
tfss = append(tfss, tfs.Finalize()...)
|
||||||
}
|
}
|
||||||
ctx.tfss = tfss
|
ctx.tfss = tfss
|
||||||
|
|
Loading…
Reference in a new issue