vmagent: fixed premature release of the context (after #4247 / #4824) (#4849)

Follow-up after a27c2f3773

https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4247

Signed-off-by: Alexander Marshalov <_@marshalov.org>
(cherry picked from commit 1e1a30ed7f)
This commit is contained in:
Alexander Marshalov 2023-08-17 12:15:03 +02:00 committed by hagen1778
parent 15bc40216d
commit 73287a7c3a
No known key found for this signature in database
GPG key ID: 3BF75F3741CA9640

View file

@ -721,9 +721,10 @@ func dropAggregatedSeries(src []prompbmarshal.TimeSeries, matchIdxs []byte, drop
func (rwctx *remoteWriteCtx) pushInternal(tss []prompbmarshal.TimeSeries) { func (rwctx *remoteWriteCtx) pushInternal(tss []prompbmarshal.TimeSeries) {
if len(labelsGlobal) > 0 { if len(labelsGlobal) > 0 {
rctx := getRelabelCtx() rctx := getRelabelCtx()
defer putRelabelCtx(rctx)
tss = rctx.appendExtraLabels(tss, labelsGlobal) tss = rctx.appendExtraLabels(tss, labelsGlobal)
putRelabelCtx(rctx)
} }
pss := rwctx.pss pss := rwctx.pss
idx := atomic.AddUint64(&rwctx.pssNextIdx, 1) % uint64(len(pss)) idx := atomic.AddUint64(&rwctx.pssNextIdx, 1) % uint64(len(pss))
pss[idx].Push(tss) pss[idx].Push(tss)