From 02c0110f2e7252d198f6b1e2e4c4adaaa55be796 Mon Sep 17 00:00:00 2001 From: Shirly Date: Wed, 10 Apr 2024 17:22:59 +0800 Subject: [PATCH] *:print down peer when the related store is not disconnected Signed-off-by: Shirly --- pkg/statistics/region_collection.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/pkg/statistics/region_collection.go b/pkg/statistics/region_collection.go index 46e92a8cace..46b01db071e 100644 --- a/pkg/statistics/region_collection.go +++ b/pkg/statistics/region_collection.go @@ -432,24 +432,28 @@ func notIsolatedStoresWithLabel(stores []*core.StoreInfo, label string) [][]*cor } // logDownPeerOnConnectedStore logs the down peers on connected stores. +// It is used to help users to know the down peer status. +// TODO: It is not a good way to log during process region heartbeat, it is a temporary solution. +// region: the region which has down peers +// stores: the stores that the peers of the region belong to. func logDownPeerOnConnectedStore(region *core.RegionInfo, stores []*core.StoreInfo) { if len(region.GetDownPeers()) == 0 { return } - downPeerOnDisconnectedStore := false + disconnectStoresNum := 0 for _, store := range stores { if store.IsDisconnected() { - downPeerOnDisconnectedStore = true - break + disconnectStoresNum++ } } - if downPeerOnDisconnectedStore { - for _, p := range region.GetDownPeers() { - log.Warn("region has down peer on connected store", - zap.Uint64("region-id", region.GetID()), - zap.Uint64("down-peer", p.Peer.Id), - zap.Uint64("down seconds", p.DownSeconds), - zap.Uint64("store-id", p.Peer.StoreId)) - } + if len(region.GetDownPeers()) == disconnectStoresNum { + return + } + for _, p := range region.GetDownPeers() { + log.Warn("region has down peer on connected store", + zap.Uint64("region-id", region.GetID()), + zap.Uint64("down-peer", p.Peer.Id), + zap.Uint64("down seconds", p.DownSeconds), + zap.Uint64("store-id", p.Peer.StoreId)) } }