From 120fe68d7fb86efff9f6227c4eee79da090bea93 Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Wed, 18 Dec 2024 15:51:55 +0800 Subject: [PATCH] fix Signed-off-by: lhy1024 --- server/region_syncer/client.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/region_syncer/client.go b/server/region_syncer/client.go index 35fd80ec3b5..5a832ef1c9f 100644 --- a/server/region_syncer/client.go +++ b/server/region_syncer/client.go @@ -164,11 +164,13 @@ func (s *RegionSyncer) StartSyncWithLeader(addr string) { } } log.Error("server failed to establish sync stream with leader", zap.String("server", s.server.Name()), zap.String("leader", s.server.GetLeader().GetName()), errs.ZapError(err)) + timer := time.NewTimer(retryInterval) select { case <-ctx.Done(): log.Info("stop synchronizing with leader due to context canceled") return - case <-time.After(retryInterval): + case <-timer.C: + timer.Stop() } continue } @@ -181,11 +183,13 @@ func (s *RegionSyncer) StartSyncWithLeader(addr string) { if err = stream.CloseSend(); err != nil { log.Error("failed to terminate client stream", errs.ZapError(errs.ErrGRPCCloseSend, err)) } + timer := time.NewTimer(retryInterval) select { case <-ctx.Done(): log.Info("stop synchronizing with leader due to context canceled") return - case <-time.After(retryInterval): + case <-timer.C: + timer.Stop() } break }