From b5c5c684ecd97ddf19b63558a79818bc7dc91fdc Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Thu, 29 Jun 2023 19:50:43 +0800 Subject: [PATCH] add timerPool.Put Signed-off-by: lhy1024 --- client/tso_dispatcher.go | 2 ++ pkg/utils/tsoutil/tso_dispatcher.go | 2 ++ 2 files changed, 4 insertions(+) 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():