Skip to content

Commit

Permalink
vendor: update github.com/VictoriaMetrics/metrics from v1.34.1 to v1.…
Browse files Browse the repository at this point in the history
…35.0

Fix potential memory leaks across VictoriaMetrics codebase after metrics.UnregisterSet(s) call
because of missing s.UnregisterAllMetrics() call.

This is a follow-up for 6a6e34a . It is OK if some vmauth metrics
aren't visible for a few microseconds when the previous metrics are unregistered and new metrics
weren't registered yet.

Updates VictoriaMetrics#6247
Updates VictoriaMetrics#4690
Updates VictoriaMetrics#6252
Updates VictoriaMetrics#5805
  • Loading branch information
valyala committed Jul 15, 2024
1 parent c995cca commit 202e570
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/vlstorage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func Init() {

// Stop stops vlstorage.
func Stop() {
metrics.UnregisterSet(storageMetrics)
metrics.UnregisterSet(storageMetrics, true)
storageMetrics = nil

strg.MustClose()
Expand Down
15 changes: 4 additions & 11 deletions app/vmauth/auth_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,22 +696,15 @@ func loadAuthConfig() (bool, error) {
}
logger.Infof("loaded information about %d users from -auth.config=%q", len(m), *authConfigPath)

prevAc := authConfig.Load()
if prevAc != nil {
metrics.UnregisterSet(prevAc.ms)
acPrev := authConfig.Load()
if acPrev != nil {
metrics.UnregisterSet(acPrev.ms, true)
}
metrics.RegisterSet(ac.ms)

authConfig.Store(ac)
authConfigData.Store(&data)
authUsers.Store(&m)
if prevAc != nil {
// explicilty unregister metrics, since all summary type metrics
// are registered at global state of metrics package
// and must be removed from it to release memory.
// Metrics must be unregistered only after atomic.Value.Store calls above
// Otherwise it may lead to metric gaps, since UnregisterAllMetrics is slow operation
prevAc.ms.UnregisterAllMetrics()
}

return true, nil
}
Expand Down
2 changes: 1 addition & 1 deletion app/vmstorage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func GetSeriesCount(deadline uint64) (uint64, error) {
// Stop stops the vmstorage
func Stop() {
// deregister storage metrics
metrics.UnregisterSet(storageMetrics)
metrics.UnregisterSet(storageMetrics, true)
storageMetrics = nil

logger.Infof("gracefully closing the storage at %s", *DataPath)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2
github.com/VictoriaMetrics/easyproto v0.1.4
github.com/VictoriaMetrics/fastcache v1.12.2
github.com/VictoriaMetrics/metrics v1.34.1
github.com/VictoriaMetrics/metrics v1.35.0
github.com/VictoriaMetrics/metricsql v0.76.0
github.com/aws/aws-sdk-go-v2 v1.30.1
github.com/aws/aws-sdk-go-v2/config v1.27.24
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ github.com/VictoriaMetrics/easyproto v0.1.4/go.mod h1:QlGlzaJnDfFd8Lk6Ci/fuLxfTo
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
github.com/VictoriaMetrics/metrics v1.34.0/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8=
github.com/VictoriaMetrics/metrics v1.34.1 h1:7EUEObv45ekfyY6PWat0K/ytluZ4q6aujzXN3g41g/A=
github.com/VictoriaMetrics/metrics v1.34.1/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8=
github.com/VictoriaMetrics/metrics v1.35.0 h1:xWImz8UTwyhGZAzueTHFgYe4bnKbXCaLWBq2JBj7EzI=
github.com/VictoriaMetrics/metrics v1.35.0/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8=
github.com/VictoriaMetrics/metricsql v0.76.0 h1:hl7vqJqyH2d8zKImzalkFrkFiD5q4ACF8gl3s86DqKA=
github.com/VictoriaMetrics/metricsql v0.76.0/go.mod h1:1g4hdCwlbJZ851PU9VN65xy9Rdlzupo6fx3SNZ8Z64U=
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
Expand Down
2 changes: 1 addition & 1 deletion lib/streamaggr/deduplicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewDeduplicator(pushFunc PushFunc, dedupInterval time.Duration, dropLabels

// MustStop stops d.
func (d *Deduplicator) MustStop() {
metrics.UnregisterSet(d.ms)
metrics.UnregisterSet(d.ms, true)
d.ms = nil

close(d.stopCh)
Expand Down
2 changes: 1 addition & 1 deletion lib/streamaggr/streamaggr.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (a *Aggregators) MustStop() {
return
}

metrics.UnregisterSet(a.ms)
metrics.UnregisterSet(a.ms, true)
a.ms = nil

for _, aggr := range a.as {
Expand Down
9 changes: 7 additions & 2 deletions vendor/github.com/VictoriaMetrics/metrics/metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ github.com/VictoriaMetrics/easyproto
# github.com/VictoriaMetrics/fastcache v1.12.2
## explicit; go 1.13
github.com/VictoriaMetrics/fastcache
# github.com/VictoriaMetrics/metrics v1.34.1
# github.com/VictoriaMetrics/metrics v1.35.0
## explicit; go 1.17
github.com/VictoriaMetrics/metrics
# github.com/VictoriaMetrics/metricsql v0.76.0
Expand Down

0 comments on commit 202e570

Please sign in to comment.