Skip to content

Commit

Permalink
Fix getting addrs on method refresh does not work as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
傅渊 committed Oct 19, 2023
1 parent 8641598 commit 5fcedd2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ func (c *Cluster) refresh(bg bool) error {
var errMsgs []string
var oldm, newm [HashSlots][]string

// get all node addrs, including replicas
addrs, _ := c.getNodeAddrs(true)
// when addrs cannot be obtained, StartupNodes is always used to populate
// get master nodes first
addrs, _ := c.getNodeAddrs(false)
if len(addrs) == 0 {
addrs = c.StartupNodes
// when master nodes cannot be obtained, try to get all replicas
if addrs, _ = c.getNodeAddrs(true); len(addrs) == 0 {
// when there is no node information, StartupNodes is always used to populate
addrs = c.StartupNodes
}
}

for _, addr := range addrs {
Expand Down

0 comments on commit 5fcedd2

Please sign in to comment.