From 48dd2b90a5578c0df2ed642fda20b890564f7a51 Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Mon, 6 Nov 2023 12:07:21 +0800 Subject: [PATCH] refactor Signed-off-by: lhy1024 --- server/core/store.go | 3 --- server/schedule/checker/rule_checker.go | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/core/store.go b/server/core/store.go index 247b1e828b3a..1556d6d09553 100644 --- a/server/core/store.go +++ b/server/core/store.go @@ -496,9 +496,6 @@ var ( // tikv's store heartbeat for a short time, maybe caused by process restart or // temporary network failure. func (s *StoreInfo) IsDisconnected() bool { - if s == nil { - return true - } return s.DownTime() > storeDisconnectDuration } diff --git a/server/schedule/checker/rule_checker.go b/server/schedule/checker/rule_checker.go index dfa17bf7b572..19c7df268a9b 100644 --- a/server/schedule/checker/rule_checker.go +++ b/server/schedule/checker/rule_checker.go @@ -408,7 +408,11 @@ func (c *RuleChecker) fixOrphanPeers(region *core.RegionInfo, fit *placement.Reg isDisconnectedPeer := func(p *metapb.Peer) bool { // avoid to meet down store when fix orphan peers, // Isdisconnected is more strictly than IsUnhealthy. - return c.cluster.GetStore(p.GetStoreId()).IsDisconnected() + store := c.cluster.GetStore(p.GetStoreId()) + if store == nil { + return true + } + return store.IsDisconnected() } checkDownPeer := func(peers []*metapb.Peer) (*metapb.Peer, bool) {