mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
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.
This commit is contained in:
parent
02b2064d8e
commit
f41a01332a
@ -18,7 +18,6 @@ import (
|
|||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/storage"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/storage"
|
||||||
"github.com/VictoriaMetrics/metrics"
|
"github.com/VictoriaMetrics/metrics"
|
||||||
xxhash "github.com/cespare/xxhash/v2"
|
xxhash "github.com/cespare/xxhash/v2"
|
||||||
jump "github.com/lithammer/go-jump-consistent-hash"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -530,7 +529,10 @@ func spreadReroutedBufToStorageNodes(sns []*storageNode, br *bufRows) {
|
|||||||
idx := uint64(0)
|
idx := uint64(0)
|
||||||
if len(sns) > 1 {
|
if len(sns) > 1 {
|
||||||
h := xxhash.Sum64(mr.MetricNameRaw)
|
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
|
attempts := 0
|
||||||
for {
|
for {
|
||||||
|
Loading…
Reference in New Issue
Block a user