From f41a01332aa98671b307564c23e4fc8f8afffc3e Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 30 May 2020 13:51:07 +0300 Subject: [PATCH] app/vminsert/netstorage: evenly distribute rerouted rows among all the availalbe storage nodes Previously such rows were distributed to the original storage node or to the next storage node. This may result to uneven load among the remaining storage nodes. --- app/vminsert/netstorage/netstorage.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/vminsert/netstorage/netstorage.go b/app/vminsert/netstorage/netstorage.go index 9b978a1c63..8e757db4b9 100644 --- a/app/vminsert/netstorage/netstorage.go +++ b/app/vminsert/netstorage/netstorage.go @@ -18,7 +18,6 @@ import ( "github.com/VictoriaMetrics/VictoriaMetrics/lib/storage" "github.com/VictoriaMetrics/metrics" xxhash "github.com/cespare/xxhash/v2" - jump "github.com/lithammer/go-jump-consistent-hash" ) var ( @@ -530,7 +529,10 @@ func spreadReroutedBufToStorageNodes(sns []*storageNode, br *bufRows) { idx := uint64(0) if len(sns) > 1 { h := xxhash.Sum64(mr.MetricNameRaw) - idx = uint64(jump.Hash(h, int32(len(sns)))) + // Do not use jump.Hash(h, int32(len(sns))) here, + // since this leads to uneven distribution of rerouted rows among sns - + // they all go to the original or to the next sn. + idx = h % uint64(len(sns)) } attempts := 0 for {