Merge pull request #1377 from davidfu13/master

Make cluster client get updated nodes' addrs
This commit is contained in:
Vladimir Mihailenco 2020-07-09 11:27:43 +03:00 committed by GitHub
commit f108b8bce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -1015,6 +1015,16 @@ func (c *ClusterClient) loadState(ctx context.Context) (*clusterState, error) {
return newClusterState(c.nodes, slots, node.Client.opt.Addr)
}
/*
* No node is connectable. It's possible that all nodes' IP has changed.
* Clear clusterAddrs to let client be able to re-connect using the initial
* setting of the addresses (e.g. [redsi-cluster-0:6379, redis-cluster-1:6379]),
* which might have chance to resolve domain name and get updated IP address.
*/
c.nodes.mu.Lock()
c.nodes.clusterAddrs = nil
c.nodes.mu.Unlock()
return nil, firstErr
}