From 73287a7c3adbe2a0bbb4246e720053374fae864f Mon Sep 17 00:00:00 2001 From: Alexander Marshalov <_@marshalov.org> Date: Thu, 17 Aug 2023 12:15:03 +0200 Subject: [PATCH] vmagent: fixed premature release of the context (after #4247 / #4824) (#4849) Follow-up after https://github.com/VictoriaMetrics/VictoriaMetrics/commit/a27c2f37731986f4bf6738404bb6388b1f42ffde https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4247 Signed-off-by: Alexander Marshalov <_@marshalov.org> (cherry picked from commit 1e1a30ed7f7a42498968332162ae65d63a30e298) --- app/vmagent/remotewrite/remotewrite.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/vmagent/remotewrite/remotewrite.go b/app/vmagent/remotewrite/remotewrite.go index ac5681aa48..b4f16ad3ef 100644 --- a/app/vmagent/remotewrite/remotewrite.go +++ b/app/vmagent/remotewrite/remotewrite.go @@ -721,9 +721,10 @@ func dropAggregatedSeries(src []prompbmarshal.TimeSeries, matchIdxs []byte, drop func (rwctx *remoteWriteCtx) pushInternal(tss []prompbmarshal.TimeSeries) { if len(labelsGlobal) > 0 { rctx := getRelabelCtx() + defer putRelabelCtx(rctx) tss = rctx.appendExtraLabels(tss, labelsGlobal) - putRelabelCtx(rctx) } + pss := rwctx.pss idx := atomic.AddUint64(&rwctx.pssNextIdx, 1) % uint64(len(pss)) pss[idx].Push(tss)