Fix corner cases and a bug

This commit is contained in:
Vladimir Mihailenco 2018-11-21 10:49:30 +02:00
parent effc0c507a
commit 18e7a81047
1 changed files with 6 additions and 3 deletions

View File

@ -533,11 +533,13 @@ func (c *clusterState) slotSlaveNode(slot int) (*clusterNode, error) {
n := rand.Intn(len(nodes)-1) + 1
slave = nodes[n]
if !slave.Loading() {
break
}
}
return slave, nil
}
}
// All slaves are loading - use master.
return nodes[0], nil
}
}
func (c *clusterState) slotClosestNode(slot int) (*clusterNode, error) {
@ -979,9 +981,10 @@ func (c *ClusterClient) defaultProcess(cmd Cmder) error {
break
}
// If slave is loading - read from master.
// If slave is loading - pick another node.
if c.opt.ReadOnly && internal.IsLoadingError(err) {
node.MarkAsLoading()
node = nil
continue
}