Merge pull request #1434 from GreenHedgehog/master

fix nil node dereference when use RouteByLatency in cluster
This commit is contained in:
Vladimir Mihailenco 2020-08-07 08:57:15 +03:00 committed by GitHub
commit 0999a925ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -564,8 +564,12 @@ func (c *clusterState) slotClosestNode(slot int) (*clusterNode, error) {
node = n
}
}
if node != nil {
return node, nil
}
// If all nodes are failing - return random node
return c.nodes.Random()
}
func (c *clusterState) slotRandomNode(slot int) (*clusterNode, error) {
nodes := c.slotNodes(slot)