mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/storage: fallback to address-based ID
Generate an ID based on storage node address if storage node is not available. This is needed in order to prevent uneven load distribution if some storage nodes are not available when vminsert is starting. Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
This commit is contained in:
parent
5ac1e77520
commit
7402ee0801
1 changed files with 8 additions and 0 deletions
|
@ -419,6 +419,14 @@ func (sn *storageNode) getID() uint64 {
|
|||
sn.checkHealth()
|
||||
}
|
||||
|
||||
// If the id is still not populated after checkHealth than storage node is not reachable
|
||||
// build a unique id based on the address
|
||||
if sn.id.Load() == 0 {
|
||||
id := xxhash.Sum64String(sn.dialer.Addr())
|
||||
sn.id.CompareAndSwap(0, id)
|
||||
return id
|
||||
}
|
||||
|
||||
return sn.id.Load()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue