Skip to content

Commit f3a31a3

Browse files
authored
Merge pull request #1684 from go-redis/fix/lazy-reload-context
Don't accept context in lazy reload
2 parents bed6d24 + b267a03 commit f3a31a3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cluster.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -632,14 +632,14 @@ func (c *clusterStateHolder) Reload(ctx context.Context) (*clusterState, error)
632632
return state, nil
633633
}
634634

635-
func (c *clusterStateHolder) LazyReload(ctx context.Context) {
635+
func (c *clusterStateHolder) LazyReload() {
636636
if !atomic.CompareAndSwapUint32(&c.reloading, 0, 1) {
637637
return
638638
}
639639
go func() {
640640
defer atomic.StoreUint32(&c.reloading, 0)
641641

642-
_, err := c.Reload(ctx)
642+
_, err := c.Reload(context.Background())
643643
if err != nil {
644644
return
645645
}
@@ -652,7 +652,7 @@ func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
652652
if v != nil {
653653
state := v.(*clusterState)
654654
if time.Since(state.createdAt) > 10*time.Second {
655-
c.LazyReload(ctx)
655+
c.LazyReload()
656656
}
657657
return state, nil
658658
}
@@ -732,7 +732,7 @@ func (c *ClusterClient) Options() *ClusterOptions {
732732
// ReloadState reloads cluster state. If available it calls ClusterSlots func
733733
// to get cluster slots information.
734734
func (c *ClusterClient) ReloadState(ctx context.Context) {
735-
c.state.LazyReload(ctx)
735+
c.state.LazyReload()
736736
}
737737

738738
// Close closes the cluster client, releasing any open resources.
@@ -793,7 +793,7 @@ func (c *ClusterClient) process(ctx context.Context, cmd Cmder) error {
793793
}
794794
if isReadOnly := isReadOnlyError(lastErr); isReadOnly || lastErr == pool.ErrClosed {
795795
if isReadOnly {
796-
c.state.LazyReload(ctx)
796+
c.state.LazyReload()
797797
}
798798
node = nil
799799
continue
@@ -1228,7 +1228,7 @@ func (c *ClusterClient) checkMovedErr(
12281228
}
12291229

12301230
if moved {
1231-
c.state.LazyReload(ctx)
1231+
c.state.LazyReload()
12321232
failedCmds.Add(node, cmd)
12331233
return true
12341234
}
@@ -1414,7 +1414,7 @@ func (c *ClusterClient) cmdsMoved(
14141414
}
14151415

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

14731473
if isReadOnly := isReadOnlyError(err); isReadOnly || err == pool.ErrClosed {
14741474
if isReadOnly {
1475-
c.state.LazyReload(ctx)
1475+
c.state.LazyReload()
14761476
}
14771477
node, err = c.slotMasterNode(ctx, slot)
14781478
if err != nil {

0 commit comments

Comments
 (0)