From c2dae136b3b01f7ccce4619687f322d0288df0ba Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 4 Mar 2024 06:01:14 +0200 Subject: [PATCH] lib/streamaggr: explicitly call resetSeries after flushSeries This makes the code less fragile --- lib/streamaggr/streamaggr.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/streamaggr/streamaggr.go b/lib/streamaggr/streamaggr.go index 19e0be433..d975f9406 100644 --- a/lib/streamaggr/streamaggr.go +++ b/lib/streamaggr/streamaggr.go @@ -674,6 +674,7 @@ func (a *aggregator) flush(pushFunc PushFunc) { ctx := getFlushCtx(a, pushFunc) as.flushState(ctx) ctx.flushSeries() + ctx.resetSeries() putFlushCtx(ctx) }(as) } @@ -925,8 +926,6 @@ func (ctx *flushCtx) flushSeries() { } auxLabels.Labels = dstLabels promutils.PutLabels(auxLabels) - - ctx.resetSeries() } func (ctx *flushCtx) appendSeries(key, suffix string, timestamp int64, value float64) { @@ -948,6 +947,7 @@ func (ctx *flushCtx) appendSeries(key, suffix string, timestamp int64, value flo // Limit the maximum length of ctx.tss in order to limit memory usage. if len(ctx.tss) >= 10_000 { ctx.flushSeries() + ctx.resetSeries() } }