From c0839116180e5675ee1651c11c0827bbcb3c0a9b Mon Sep 17 00:00:00 2001 From: HunDunDM Date: Tue, 25 May 2021 15:58:06 +0800 Subject: [PATCH] store/helper, infoschema: fix the bug that cannot find down-peer Signed-off-by: HunDunDM --- executor/infoschema_reader.go | 8 ++++---- store/helper/helper.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/executor/infoschema_reader.go b/executor/infoschema_reader.go index ee5b4af84b574..d049fb3eb39e8 100644 --- a/executor/infoschema_reader.go +++ b/executor/infoschema_reader.go @@ -1410,7 +1410,7 @@ func (e *memtableRetriever) setNewTiKVRegionPeersCols(region *helper.RegionInfo) } downPeerMap := make(map[int64]int64, len(region.DownPeers)) for _, peerStat := range region.DownPeers { - downPeerMap[peerStat.ID] = peerStat.DownSec + downPeerMap[peerStat.Peer.ID] = peerStat.DownSec } for _, peer := range region.Peers { row := make([]types.Datum, len(infoschema.TableTiKVRegionPeersCols)) @@ -1427,11 +1427,11 @@ func (e *memtableRetriever) setNewTiKVRegionPeersCols(region *helper.RegionInfo) } else { row[4].SetInt64(0) } - if pendingPeerIDSet.Exist(peer.ID) { - row[5].SetString(pendingPeer, mysql.DefaultCollationName) - } else if downSec, ok := downPeerMap[peer.ID]; ok { + if downSec, ok := downPeerMap[peer.ID]; ok { row[5].SetString(downPeer, mysql.DefaultCollationName) row[6].SetInt64(downSec) + } else if pendingPeerIDSet.Exist(peer.ID) { + row[5].SetString(pendingPeer, mysql.DefaultCollationName) } else { row[5].SetString(normalPeer, mysql.DefaultCollationName) } diff --git a/store/helper/helper.go b/store/helper/helper.go index 8eb9b9d7db828..8e12b9259a756 100644 --- a/store/helper/helper.go +++ b/store/helper/helper.go @@ -467,8 +467,8 @@ type RegionEpoch struct { // RegionPeerStat stores one field `DownSec` which indicates how long it's down than `RegionPeer`. type RegionPeerStat struct { - RegionPeer - DownSec int64 `json:"down_seconds"` + Peer RegionPeer `json:"peer"` + DownSec int64 `json:"down_seconds"` } // RegionInfo stores the information of one region.