diff --git a/client/tso_dispatcher.go b/client/tso_dispatcher.go index a41618ee7e6..6c644e2a6e0 100644 --- a/client/tso_dispatcher.go +++ b/client/tso_dispatcher.go @@ -211,6 +211,8 @@ func (c *tsoClient) watchTSDeadline(ctx context.Context, dcLocation string) { timerPool.Put(d.timer) continue case <-ctx.Done(): + d.timer.Stop() // not received from timer.C, so we need to stop the timer + timerPool.Put(d.timer) return } case <-ctx.Done(): diff --git a/pkg/utils/tsoutil/tso_dispatcher.go b/pkg/utils/tsoutil/tso_dispatcher.go index 2679226124b..875b1ab925f 100644 --- a/pkg/utils/tsoutil/tso_dispatcher.go +++ b/pkg/utils/tsoutil/tso_dispatcher.go @@ -243,6 +243,8 @@ func WatchTSDeadline(ctx context.Context, tsDeadlineCh <-chan *TSDeadline) { timerPool.Put(d.timer) continue case <-ctx.Done(): + d.timer.Stop() // not received from timer.C, so we need to stop the timer + timerPool.Put(d.timer) return } case <-ctx.Done():