diff --git a/cluster.go b/cluster.go index f283722..47b7924 100644 --- a/cluster.go +++ b/cluster.go @@ -844,15 +844,12 @@ func (c *ClusterClient) Watch(fn func(*Tx) error, keys ...string) error { if err == nil { break } - - if internal.IsRetryableError(err, true) { + if err != Nil { c.state.LazyReload() - continue } moved, ask, addr := internal.IsMovedError(err) if moved || ask { - c.state.LazyReload() node, err = c.nodes.GetOrCreate(addr) if err != nil { return err @@ -868,6 +865,10 @@ func (c *ClusterClient) Watch(fn func(*Tx) error, keys ...string) error { continue } + if internal.IsRetryableError(err, true) { + continue + } + return err } @@ -932,6 +933,9 @@ func (c *ClusterClient) defaultProcess(cmd Cmder) error { if err == nil { break } + if err != Nil { + c.state.LazyReload() + } // If slave is loading - pick another node. if c.opt.ReadOnly && internal.IsLoadingError(err) { @@ -940,9 +944,23 @@ func (c *ClusterClient) defaultProcess(cmd Cmder) error { continue } - if internal.IsRetryableError(err, true) { - c.state.LazyReload() + var moved bool + var addr string + moved, ask, addr = internal.IsMovedError(err) + if moved || ask { + node, err = c.nodes.GetOrCreate(addr) + if err != nil { + break + } + continue + } + if err == pool.ErrClosed { + node = nil + continue + } + + if internal.IsRetryableError(err, true) { // First retry the same node. if attempt == 0 { continue @@ -956,24 +974,6 @@ func (c *ClusterClient) defaultProcess(cmd Cmder) error { continue } - var moved bool - var addr string - moved, ask, addr = internal.IsMovedError(err) - if moved || ask { - c.state.LazyReload() - - node, err = c.nodes.GetOrCreate(addr) - if err != nil { - break - } - continue - } - - if err == pool.ErrClosed { - node = nil - continue - } - break }