Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the reliability of the refresh process due to the loss of slots #52

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading