Tweak auto-reloads

This commit is contained in:
Vladimir Mihailenco 2020-06-29 17:39:59 +03:00
parent 0ffefcde98
commit 64995f9a51
2 changed files with 4 additions and 10 deletions

View File

@ -622,7 +622,7 @@ func (c *clusterStateHolder) LazyReload(ctx context.Context) {
if err != nil { if err != nil {
return return
} }
time.Sleep(100 * time.Millisecond) time.Sleep(250 * time.Millisecond)
}() }()
} }
@ -630,7 +630,7 @@ func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
v := c.state.Load() v := c.state.Load()
if v != nil { if v != nil {
state := v.(*clusterState) state := v.(*clusterState)
if time.Since(state.createdAt) > time.Minute { if time.Since(state.createdAt) > 10*time.Second {
c.LazyReload(ctx) c.LazyReload(ctx)
} }
return state, nil return state, nil
@ -780,9 +780,6 @@ func (c *ClusterClient) _process(ctx context.Context, cmd Cmder) error {
if lastErr == nil { if lastErr == nil {
return nil return nil
} }
if lastErr != Nil {
c.state.LazyReload(ctx)
}
if lastErr == pool.ErrClosed || isReadOnlyError(lastErr) { if lastErr == pool.ErrClosed || isReadOnlyError(lastErr) {
node = nil node = nil
continue continue
@ -1431,9 +1428,6 @@ func (c *ClusterClient) Watch(ctx context.Context, fn func(*Tx) error, keys ...s
if err == nil { if err == nil {
break break
} }
if err != Nil {
c.state.LazyReload(ctx)
}
moved, ask, addr := isMovedError(err) moved, ask, addr := isMovedError(err)
if moved || ask { if moved || ask {

View File

@ -43,8 +43,8 @@ var _ = Describe("HashSlot", func() {
{"{}foo", 9500}, {"{}foo", 9500},
{"foo{}", 5542}, {"foo{}", 5542},
{"foo{}{bar}", 8363}, {"foo{}{bar}", 8363},
{"", 10503}, {"", 7404},
{"", 5176}, {"", 4403},
{string([]byte{83, 153, 134, 118, 229, 214, 244, 75, 140, 37, 215, 215}), 5463}, {string([]byte{83, 153, 134, 118, 229, 214, 244, 75, 140, 37, 215, 215}), 5463},
} }
// Empty keys receive random slot. // Empty keys receive random slot.