From c18017a9c3e4483f3ab3a0a148a57236a265dfd7 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 23 Jun 2021 14:00:06 +0300 Subject: [PATCH] app/vminsert/netstorage: sort the `-storageNode` list passed to `vminsert` nodes This should reduce resource usage (CPU, RAM, disk IO) at vmstorage nodes if the addresses of vmstorage nodes are passed in random order to vminsert nodes. --- app/vminsert/netstorage/netstorage.go | 6 ++++++ docs/CHANGELOG.md | 1 + 2 files changed, 7 insertions(+) diff --git a/app/vminsert/netstorage/netstorage.go b/app/vminsert/netstorage/netstorage.go index 1fdf001093..70c678d765 100644 --- a/app/vminsert/netstorage/netstorage.go +++ b/app/vminsert/netstorage/netstorage.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "io" + "sort" "sync" "sync/atomic" "time" @@ -400,6 +401,11 @@ func InitStorageNodes(addrs []string) { logger.Panicf("BUG: too much addresses: %d; max supported %d addresses", len(addrs), 255) } + // Sort addrs in order to guarantee identical series->vmstorage mapping across all the vminsert nodes. + addrsCopy := append([]string{}, addrs...) + sort.Strings(addrsCopy) + addrs = addrsCopy + storageNodes = storageNodes[:0] for _, addr := range addrs { sn := &storageNode{ diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3b7efab644..26dece6956 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,7 @@ sort: 15 * FEATURE: vmagent: support generic auth configs in `consul_sd_configs` in the same way as Prometheus 2.28 does. See [this issue](https://github.com/prometheus/prometheus/issues/8924) for details. * FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): limit the number of samples per each imported JSON line. This should limit the memory usage at VictoriaMetrics side when importing time series with big number of samples. * FEATURE: vmselect: log slow queries across all the `/api/v1/*` handlers (aka [Prometheus query API](https://prometheus.io/docs/prometheus/latest/querying/api)) if their execution duration exceeds `-search.logSlowQueryDuration`. This should simplify debugging slow requests to such handlers as `/api/v1/labels` or `/api/v1/series` additionally to `/api/v1/query` and `/api/v1/query_range`, which were logged in the previous releases. +* FEATURE: vminsert: sort the `-storageNode` list in order to guarantee the identical `series -> vmstorage` mapping across all the `vminsert` nodes. This should reduce resource usage (RAM, CPU and disk IO) at `vmstorage` nodes if `vmstorage` addresses are passed in random order to `vminsert` nodes. * BUGFIX: prevent from adding new samples to deleted time series after the rotation of the inverted index (the rotation is performed once per `-retentionPeriod`). See [this comment](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1347#issuecomment-861232136) for details. * BUGFIX: vmstorage: reduce high disk write IO usage on systems with big number of CPU cores. The issue has been introduced in the release [v1.59.0](#v1590). See [this commit](aa9b56a046b6ae8083fa659df35dd5e994bf9115) and [this comment](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1338#issuecomment-863046999) for details.