Skip to content

Commit

Permalink
Merge pull request redis#1684 from go-redis/fix/lazy-reload-context
Browse files Browse the repository at this point in the history
Don't accept context in lazy reload
  • Loading branch information
vmihailenco authored Mar 5, 2021
2 parents bed6d24 + b267a03 commit f3a31a3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,14 @@ func (c *clusterStateHolder) Reload(ctx context.Context) (*clusterState, error)
return state, nil
}

func (c *clusterStateHolder) LazyReload(ctx context.Context) {
func (c *clusterStateHolder) LazyReload() {
if !atomic.CompareAndSwapUint32(&c.reloading, 0, 1) {
return
}
go func() {
defer atomic.StoreUint32(&c.reloading, 0)

_, err := c.Reload(ctx)
_, err := c.Reload(context.Background())
if err != nil {
return
}
Expand All @@ -652,7 +652,7 @@ func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
if v != nil {
state := v.(*clusterState)
if time.Since(state.createdAt) > 10*time.Second {
c.LazyReload(ctx)
c.LazyReload()
}
return state, nil
}
Expand Down Expand Up @@ -732,7 +732,7 @@ func (c *ClusterClient) Options() *ClusterOptions {
// ReloadState reloads cluster state. If available it calls ClusterSlots func
// to get cluster slots information.
func (c *ClusterClient) ReloadState(ctx context.Context) {
c.state.LazyReload(ctx)
c.state.LazyReload()
}

// Close closes the cluster client, releasing any open resources.
Expand Down Expand Up @@ -793,7 +793,7 @@ func (c *ClusterClient) process(ctx context.Context, cmd Cmder) error {
}
if isReadOnly := isReadOnlyError(lastErr); isReadOnly || lastErr == pool.ErrClosed {
if isReadOnly {
c.state.LazyReload(ctx)
c.state.LazyReload()
}
node = nil
continue
Expand Down Expand Up @@ -1228,7 +1228,7 @@ func (c *ClusterClient) checkMovedErr(
}

if moved {
c.state.LazyReload(ctx)
c.state.LazyReload()
failedCmds.Add(node, cmd)
return true
}
Expand Down Expand Up @@ -1414,7 +1414,7 @@ func (c *ClusterClient) cmdsMoved(
}

if moved {
c.state.LazyReload(ctx)
c.state.LazyReload()
for _, cmd := range cmds {
failedCmds.Add(node, cmd)
}
Expand Down Expand Up @@ -1472,7 +1472,7 @@ func (c *ClusterClient) Watch(ctx context.Context, fn func(*Tx) error, keys ...s

if isReadOnly := isReadOnlyError(err); isReadOnly || err == pool.ErrClosed {
if isReadOnly {
c.state.LazyReload(ctx)
c.state.LazyReload()
}
node, err = c.slotMasterNode(ctx, slot)
if err != nil {
Expand Down

0 comments on commit f3a31a3

Please sign in to comment.