diff --git a/client/resource_group/controller/controller.go b/client/resource_group/controller/controller.go index e5161ad9e3e..0bbda058b30 100755 --- a/client/resource_group/controller/controller.go +++ b/client/resource_group/controller/controller.go @@ -294,7 +294,7 @@ func (c *ResourceGroupsController) Start(ctx context.Context) { log.Warn("watch resource group meta failed", zap.Error(err)) timerutil.SafeResetTimer(watchRetryTimer, watchRetryInterval) failpoint.Inject("watchStreamError", func() { - watchRetryTimer.Reset(20 * time.Millisecond) + timerutil.SafeResetTimer(watchRetryTimer, 20*time.Millisecond) }) } } @@ -338,7 +338,7 @@ func (c *ResourceGroupsController) Start(ctx context.Context) { watchMetaChannel = nil timerutil.SafeResetTimer(watchRetryTimer, watchRetryInterval) failpoint.Inject("watchStreamError", func() { - watchRetryTimer.Reset(20 * time.Millisecond) + timerutil.SafeResetTimer(watchRetryTimer, 20*time.Millisecond) }) continue } @@ -374,7 +374,7 @@ func (c *ResourceGroupsController) Start(ctx context.Context) { watchConfigChannel = nil timerutil.SafeResetTimer(watchRetryTimer, watchRetryInterval) failpoint.Inject("watchStreamError", func() { - watchRetryTimer.Reset(20 * time.Millisecond) + timerutil.SafeResetTimer(watchRetryTimer, 20*time.Millisecond) }) continue } @@ -527,7 +527,7 @@ func (c *ResourceGroupsController) sendTokenBucketRequests(ctx context.Context, ClientUniqueId: c.clientUniqueID, } if c.ruConfig.DegradedModeWaitDuration > 0 && c.responseDeadlineCh == nil { - c.run.responseDeadline.Reset(c.ruConfig.DegradedModeWaitDuration) + timerutil.SafeResetTimer(c.run.responseDeadline, c.ruConfig.DegradedModeWaitDuration) c.responseDeadlineCh = c.run.responseDeadline.C } go func() { diff --git a/client/retry/backoff.go b/client/retry/backoff.go index 9161ad0fea1..d24e92ca0be 100644 --- a/client/retry/backoff.go +++ b/client/retry/backoff.go @@ -24,6 +24,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/failpoint" "github.com/pingcap/log" + "github.com/tikv/pd/client/timerutil" "go.uber.org/zap" ) @@ -86,7 +87,7 @@ func (bo *Backoffer) Exec( if after == nil { after = time.NewTimer(currentInterval) } else { - after.Reset(currentInterval) + timerutil.SafeResetTimer(after, currentInterval) } select { case <-ctx.Done():