Skip to content

Commit

Permalink
store/helper, infoschema: fix the bug that cannot find down-peer (#24881
Browse files Browse the repository at this point in the history
) (#24918)
  • Loading branch information
ti-srebot authored Jul 8, 2021
1 parent 6f46f2d commit 3be56ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,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))
Expand All @@ -1216,11 +1216,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)
}
Expand Down
4 changes: 2 additions & 2 deletions store/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,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.
Expand Down

0 comments on commit 3be56ed

Please sign in to comment.