diff --git a/app/vmagent/remotewrite/remotewrite.go b/app/vmagent/remotewrite/remotewrite.go index 779e48f62b..ab8f1f0bda 100644 --- a/app/vmagent/remotewrite/remotewrite.go +++ b/app/vmagent/remotewrite/remotewrite.go @@ -587,6 +587,11 @@ func newRemoteWriteCtx(argIdx int, at *auth.Token, remoteWriteURL *url.URL, maxI } func (rwctx *remoteWriteCtx) MustStop() { + // sas must be stopped before rwctx is closed + // because sas can write pending series to rwctx.pss if there are any + sas := rwctx.sas.Swap(nil) + sas.MustStop() + for _, ps := range rwctx.pss { ps.MustStop() } @@ -596,9 +601,6 @@ func (rwctx *remoteWriteCtx) MustStop() { rwctx.c.MustStop() rwctx.c = nil - sas := rwctx.sas.Swap(nil) - sas.MustStop() - rwctx.fq.MustClose() rwctx.fq = nil diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2db49ea736..fd5f48d1cd 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -31,6 +31,7 @@ The following tip changes can be tested by building VictoriaMetrics components f `--search.maxGraphiteTagKeys` for limiting the number of tag keys returned from Graphite `/tags`, `/tags/autoComplete/*`, `/tags/findSeries` API. `--search.maxGraphiteTagValues` for limiting the number of tag values returned Graphite `/tags/` API. Remove redundant limit from [Prometheus api/v1/series](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#prometheus-querying-api-usage). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4339). +* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix panic on vmagent shutdown which could lead to loosing aggregation results which were not flushed to remote yet. See [this](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4407) for details. ## [v1.91.2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.91.2)