Skip to content

Commit

Permalink
Merge pull request #52 from ljfuyuan/master
Browse files Browse the repository at this point in the history
Improve the reliability of the refresh process.
  • Loading branch information
mna authored Oct 20, 2023
2 parents 5aef5f5 + 5fcedd2 commit 70c449d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ func (c *Cluster) refresh(bg bool) error {
var errMsgs []string
var oldm, newm [HashSlots][]string

// get master nodes first
addrs, _ := c.getNodeAddrs(false)
if len(addrs) == 0 {
// 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 {
m, err := c.getClusterSlots(addr)
if err != nil {
Expand Down

0 comments on commit 70c449d

Please sign in to comment.