From 64995f9a51af413c22a06cd9c4af18350095548a Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 29 Jun 2020 17:39:59 +0300 Subject: [PATCH] Tweak auto-reloads --- cluster.go | 10 ++-------- internal/hashtag/hashtag_test.go | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cluster.go b/cluster.go index 4747a0e6..3db0c83a 100644 --- a/cluster.go +++ b/cluster.go @@ -622,7 +622,7 @@ func (c *clusterStateHolder) LazyReload(ctx context.Context) { if err != nil { 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() if v != nil { state := v.(*clusterState) - if time.Since(state.createdAt) > time.Minute { + if time.Since(state.createdAt) > 10*time.Second { c.LazyReload(ctx) } return state, nil @@ -780,9 +780,6 @@ func (c *ClusterClient) _process(ctx context.Context, cmd Cmder) error { if lastErr == nil { return nil } - if lastErr != Nil { - c.state.LazyReload(ctx) - } if lastErr == pool.ErrClosed || isReadOnlyError(lastErr) { node = nil continue @@ -1431,9 +1428,6 @@ func (c *ClusterClient) Watch(ctx context.Context, fn func(*Tx) error, keys ...s if err == nil { break } - if err != Nil { - c.state.LazyReload(ctx) - } moved, ask, addr := isMovedError(err) if moved || ask { diff --git a/internal/hashtag/hashtag_test.go b/internal/hashtag/hashtag_test.go index c84e1139..87aca6ff 100644 --- a/internal/hashtag/hashtag_test.go +++ b/internal/hashtag/hashtag_test.go @@ -43,8 +43,8 @@ var _ = Describe("HashSlot", func() { {"{}foo", 9500}, {"foo{}", 5542}, {"foo{}{bar}", 8363}, - {"", 10503}, - {"", 5176}, + {"", 7404}, + {"", 4403}, {string([]byte{83, 153, 134, 118, 229, 214, 244, 75, 140, 37, 215, 215}), 5463}, } // Empty keys receive random slot.