From 491831df4930549827697959c3359bc330251589 Mon Sep 17 00:00:00 2001 From: Roman Khavronenko Date: Tue, 9 May 2023 17:33:58 +0200 Subject: [PATCH] vminsert: properly reset labels object on aggregation (#4278) Without reset, labels duplicates could have been added during stream aggregation. Since `ctx.Labels` is reused during processing of many series, each series will add its labels to the context. Even if the same labels were already addeded on prev iteration. Now, we reset `ctx.Labels` on each iteration to contain so labels from different series didn't interfere. This could have cause exceeding of the limit on number of labels per pushed time series. https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4277 Signed-off-by: hagen1778 --- app/vminsert/common/streamaggr.go | 1 + docs/CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/app/vminsert/common/streamaggr.go b/app/vminsert/common/streamaggr.go index 6a512c81c..d45cf86d8 100644 --- a/app/vminsert/common/streamaggr.go +++ b/app/vminsert/common/streamaggr.go @@ -174,6 +174,7 @@ func pushAggregateSeries(tss []prompbmarshal.TimeSeries) { ctx.skipStreamAggr = true for _, ts := range tss { labels := ts.Labels + ctx.Labels = ctx.Labels[:0] for _, label := range labels { name := label.Name if name == "__name__" { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f81a128cd..51a3c01f6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -65,6 +65,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * BUGFIX: [alerts-health](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/deployment/docker/alerts-health.yml): update threshold for `TooHighMemoryUsage` alert from 90% to 80%, since 90% is too high for production environments. * BUGFIX: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): fix compatibility with Windows OS. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/70). * BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): fix performance issue when migrating data from VictoriaMetrics according to [these docs](https://docs.victoriametrics.com/vmctl.html#migrating-data-from-victoriametrics). Add the ability to speed up the data migration via `--vm-native-disable-retries` command-line flag. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4092). +* BUGFIX: [stream aggregation](https://docs.victoriametrics.com/stream-aggregation.html): fix bug with duplicated labels during stream aggregation via single-node VictoriaMetrics. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4277). ## [v1.90.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.90.0)