@@ -31,6 +31,7 @@ import (
3131 "github.com/prometheus/client_golang/prometheus"
3232 pd "github.com/tikv/pd/client"
3333 "github.com/tikv/pd/client/errs"
34+ "github.com/tikv/pd/client/timerutil"
3435 atomicutil "go.uber.org/atomic"
3536 "go.uber.org/zap"
3637)
@@ -286,17 +287,17 @@ func (c *ResourceGroupsController) Start(ctx context.Context) {
286287 watchMetaChannel , err = c .provider .Watch (ctx , pd .GroupSettingsPathPrefixBytes , pd .WithRev (metaRevision ), pd .WithPrefix (), pd .WithPrevKV ())
287288 if err != nil {
288289 log .Warn ("watch resource group meta failed" , zap .Error (err ))
289- watchRetryTimer . Reset ( watchRetryInterval )
290+ timerutil . SafeResetTimer ( watchRetryTimer , watchRetryInterval )
290291 failpoint .Inject ("watchStreamError" , func () {
291- watchRetryTimer . Reset ( 20 * time .Millisecond )
292+ timerutil . SafeResetTimer ( watchRetryTimer , 20 * time .Millisecond )
292293 })
293294 }
294295 }
295296 if watchConfigChannel == nil {
296297 watchConfigChannel , err = c .provider .Watch (ctx , pd .ControllerConfigPathPrefixBytes , pd .WithRev (cfgRevision ), pd .WithPrefix ())
297298 if err != nil {
298299 log .Warn ("watch resource group config failed" , zap .Error (err ))
299- watchRetryTimer . Reset ( watchRetryInterval )
300+ timerutil . SafeResetTimer ( watchRetryTimer , watchRetryInterval )
300301 }
301302 }
302303 case <- emergencyTokenAcquisitionTicker .C :
@@ -330,9 +331,9 @@ func (c *ResourceGroupsController) Start(ctx context.Context) {
330331 })
331332 if ! ok {
332333 watchMetaChannel = nil
333- watchRetryTimer . Reset ( watchRetryInterval )
334+ timerutil . SafeResetTimer ( watchRetryTimer , watchRetryInterval )
334335 failpoint .Inject ("watchStreamError" , func () {
335- watchRetryTimer . Reset ( 20 * time .Millisecond )
336+ timerutil . SafeResetTimer ( watchRetryTimer , 20 * time .Millisecond )
336337 })
337338 continue
338339 }
@@ -366,9 +367,9 @@ func (c *ResourceGroupsController) Start(ctx context.Context) {
366367 case resp , ok := <- watchConfigChannel :
367368 if ! ok {
368369 watchConfigChannel = nil
369- watchRetryTimer . Reset ( watchRetryInterval )
370+ timerutil . SafeResetTimer ( watchRetryTimer , watchRetryInterval )
370371 failpoint .Inject ("watchStreamError" , func () {
371- watchRetryTimer . Reset ( 20 * time .Millisecond )
372+ timerutil . SafeResetTimer ( watchRetryTimer , 20 * time .Millisecond )
372373 })
373374 continue
374375 }
@@ -521,7 +522,7 @@ func (c *ResourceGroupsController) sendTokenBucketRequests(ctx context.Context,
521522 ClientUniqueId : c .clientUniqueID ,
522523 }
523524 if c .ruConfig .DegradedModeWaitDuration > 0 && c .responseDeadlineCh == nil {
524- c .run .responseDeadline . Reset ( c .ruConfig .DegradedModeWaitDuration )
525+ timerutil . SafeResetTimer ( c .run .responseDeadline , c .ruConfig .DegradedModeWaitDuration )
525526 c .responseDeadlineCh = c .run .responseDeadline .C
526527 }
527528 go func () {
0 commit comments