-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Check Failing() before serving random node #1825
Check Failing() before serving random node #1825
Conversation
cluster.go
Outdated
return nodes[idx], nil | ||
} | ||
} | ||
return c.nodes.Random() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch - thanks 👍
Does it make sense to try random node here? It will result in MOVED error and will re-try the command again on the same failing nodes.
I think we should:
- remove
c.nodes.Random()
and just use first/random failing node as we did previously - add an optimization for
len(nodes) == 1
sincerand.Perm
is somewhat expensive
if len(nodes) == 1 {
return nodes[0]
}
cluster.go
Outdated
n := rand.Intn(len(nodes)) | ||
return nodes[n], nil | ||
for _, idx := range rand.Perm(len(nodes)) { | ||
if !nodes[idx].Failing() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly better:
if node := nodes[idx]; !node.Failing() {
return node, nil
}
Thanks! |
There are still some other issues that need to be resolved, we will release a new version later. |
We encounter errors during Redis failover with
RouteRandomly
set totrue
.After some debugging we found that
Failing
is never checked when serving random node for the slot.This should be pretty easy to reproduce:
docker-compose exec redis-cluster supervisorctl stop redis-2