From 09e1549e0684a7123703af19e7215a83d0d00917 Mon Sep 17 00:00:00 2001 From: chuntaojun Date: Sat, 29 Jun 2024 11:55:40 +0800 Subject: [PATCH] fix --- plugin/healthchecker/leader/checker_leader.go | 22 ------------------- plugin/healthchecker/leader/peer.go | 2 ++ 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/plugin/healthchecker/leader/checker_leader.go b/plugin/healthchecker/leader/checker_leader.go index 227f2c03e..de92300d2 100644 --- a/plugin/healthchecker/leader/checker_leader.go +++ b/plugin/healthchecker/leader/checker_leader.go @@ -482,28 +482,6 @@ const ( maxCheckCount = 3 ) -func (c *LeaderHealthChecker) checkLeaderAlive(ctx context.Context) { - ticker := time.NewTicker(time.Second) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - peer := c.findLeaderPeer() - if peer == nil { - // 可能是在 Leader 调整中,不处理探测 - continue - } - - if !peer.IsAlive() { - log.Info("[Health Check][Leader] leader peer not alive, do suspend") - c.Suspend() - } - } - } -} - func (c *LeaderHealthChecker) DebugHandlers() []model.DebugHandler { return []model.DebugHandler{ { diff --git a/plugin/healthchecker/leader/peer.go b/plugin/healthchecker/leader/peer.go index eba5d4eee..ad143bb8a 100644 --- a/plugin/healthchecker/leader/peer.go +++ b/plugin/healthchecker/leader/peer.go @@ -289,6 +289,8 @@ func (p *RemotePeer) checkLeaderAlive(ctx context.Context) { select { case <-ctx.Done(): ticker.Stop() + plog.Info("check leader alive job stop", zap.String("host", p.Host()), zap.Uint32("port", p.port)) + return case <-ticker.C: var errCount int for i := 0; i < maxCheckCount; i++ {