diff --git a/app/vminsert/netstorage/netstorage.go b/app/vminsert/netstorage/netstorage.go index a72d7a476..28b79bdc4 100644 --- a/app/vminsert/netstorage/netstorage.go +++ b/app/vminsert/netstorage/netstorage.go @@ -45,6 +45,9 @@ var ( "On the other side, disabled re-routing minimizes the number of active time series in the cluster "+ "during rolling restarts and during spikes in series churn rate. "+ "See also -disableRerouting") + usePersistentStorageNodeID = flag.Bool("vmstorageUsePersistentID", false, "Whether to use persistent storage node ID for -storageNode instances. "+ + "If set to false uses storage node address in order to generate an ID. "+ + "Using persistent node ID is useful if vmstorage node address changes over time, e.g. due to dynamic IP addresses or DNS names. ") ) var errStorageReadOnly = errors.New("storage node is read only") @@ -608,7 +611,14 @@ func initStorageNodes(addrs []string, hashSeed uint64) *storageNodesBucket { } return 0 }) - nodeIDs = append(nodeIDs, sn.getID()) + var nodeID uint64 + if *usePersistentStorageNodeID { + nodeID = sn.getID() + } else { + nodeID = xxhash.Sum64String(addr) + } + + nodeIDs = append(nodeIDs, nodeID) sns = append(sns, sn) } nodesHash := newConsistentHash(nodeIDs, hashSeed) diff --git a/docs/Cluster-VictoriaMetrics.md b/docs/Cluster-VictoriaMetrics.md index b294d6dda..7c390ab20 100644 --- a/docs/Cluster-VictoriaMetrics.md +++ b/docs/Cluster-VictoriaMetrics.md @@ -1301,6 +1301,8 @@ Below is the output for `/path/to/vminsert -help`: Show VictoriaMetrics version -vmstorageDialTimeout duration Timeout for establishing RPC connections from vminsert to vmstorage. See also -vmstorageUserTimeout (default 3s) + -vmstorageUsePersistentID + Whether to use persistent storage node ID for -storageNode instances. If set to false uses storage node address in order to generate an ID. Using persistent node ID is useful if vmstorage node address changes over time, e.g. due to dynamic IP addresses or DNS names. -vmstorageUserTimeout duration Network timeout for RPC connections from vminsert to vmstorage (Linux only). Lower values speed up re-rerouting recovery when some of vmstorage nodes become unavailable because of networking issues. Read more about TCP_USER_TIMEOUT at https://blog.cloudflare.com/when-tcp-sockets-refuse-to-die/ . See also -vmstorageDialTimeout (default 3s) ```