mirror of
https://github.com/redis/go-redis.git
synced 2025-07-31 05:04:23 +03:00
if readonly, read from master when slave is loading
This commit is contained in:
11
cluster.go
11
cluster.go
@ -300,6 +300,17 @@ func (c *ClusterClient) Process(cmd Cmder) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If slave is loading, read from master
|
||||
if errors.IsLoading(cmd.Err()) && c.opt.ReadOnly {
|
||||
trynode, err := c.slotMasterNode(slot)
|
||||
if err == nil && trynode != node {
|
||||
node = trynode
|
||||
continue
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// On network errors try random node.
|
||||
if errors.IsRetryable(err) {
|
||||
node, err = c.randomNode()
|
||||
|
Reference in New Issue
Block a user