Reload state on read only error

This commit is contained in:
Vladimir Mihailenco 2020-06-30 11:13:15 +03:00
parent ac72610544
commit dc52593c8c
1 changed files with 8 additions and 2 deletions

View File

@ -780,7 +780,10 @@ func (c *ClusterClient) _process(ctx context.Context, cmd Cmder) error {
if lastErr == nil { if lastErr == nil {
return nil return nil
} }
if lastErr == pool.ErrClosed || isReadOnlyError(lastErr) { if isReadOnly := isReadOnlyError(lastErr); isReadOnly || lastErr == pool.ErrClosed {
if isReadOnly {
c.state.LazyReload(ctx)
}
node = nil node = nil
continue continue
} }
@ -1438,7 +1441,10 @@ func (c *ClusterClient) Watch(ctx context.Context, fn func(*Tx) error, keys ...s
continue continue
} }
if err == pool.ErrClosed || isReadOnlyError(err) { if isReadOnly := isReadOnlyError(err); isReadOnly || err == pool.ErrClosed {
if isReadOnly {
c.state.LazyReload(ctx)
}
node, err = c.slotMasterNode(ctx, slot) node, err = c.slotMasterNode(ctx, slot)
if err != nil { if err != nil {
return err return err