Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed May 24, 2024
1 parent 09497bf commit 668ca97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
12 changes: 9 additions & 3 deletions pkg/mock/mockcluster/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,23 +894,29 @@ func (mc *Cluster) CheckRegionRead(region *core.RegionInfo) []*statistics.HotPee
items := make([]*statistics.HotPeerStat, 0)
expiredItems := mc.HotCache.ExpiredReadItems(region)
items = append(items, expiredItems...)
return append(items, mc.HotCache.CheckReadPeerSync(region, nil, region.GetInterval().GetEndTimestamp()-region.GetInterval().GetStartTimestamp())...)
reportInterval := region.GetInterval()
interval := reportInterval.GetEndTimestamp() - reportInterval.GetStartTimestamp()
return append(items, mc.HotCache.CheckReadPeerSync(region, nil, interval)...)
}

// CheckRegionWrite checks region write info with all peers
func (mc *Cluster) CheckRegionWrite(region *core.RegionInfo) []*statistics.HotPeerStat {
items := make([]*statistics.HotPeerStat, 0)
expiredItems := mc.HotCache.ExpiredWriteItems(region)
items = append(items, expiredItems...)
return append(items, mc.HotCache.CheckWritePeerSync(region, nil, region.GetInterval().GetEndTimestamp()-region.GetInterval().GetStartTimestamp())...)
reportInterval := region.GetInterval()
interval := reportInterval.GetEndTimestamp() - reportInterval.GetStartTimestamp()
return append(items, mc.HotCache.CheckWritePeerSync(region, nil, interval)...)
}

// CheckRegionLeaderRead checks region read info with leader peer
func (mc *Cluster) CheckRegionLeaderRead(region *core.RegionInfo) []*statistics.HotPeerStat {
items := make([]*statistics.HotPeerStat, 0)
expiredItems := mc.HotCache.ExpiredReadItems(region)
items = append(items, expiredItems...)
return append(items, mc.HotCache.CheckReadPeerSync(region, nil, region.GetInterval().GetEndTimestamp()-region.GetInterval().GetStartTimestamp())...)
reportInterval := region.GetInterval()
interval := reportInterval.GetEndTimestamp() - reportInterval.GetStartTimestamp()
return append(items, mc.HotCache.CheckReadPeerSync(region, nil, interval)...)
}

// ObserveRegionsStats records the current stores stats from region stats.
Expand Down
4 changes: 3 additions & 1 deletion pkg/statistics/hot_peer_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ func orderingPeers(cache *hotPeerCache, region *core.RegionInfo) []*metapb.Peer
}

func checkFlow(cache *hotPeerCache, region *core.RegionInfo, peers []*metapb.Peer) (res []*HotPeerStat) {
reportInterval := region.GetInterval()
interval := reportInterval.GetEndTimestamp() - reportInterval.GetStartTimestamp()
res = append(res, cache.collectExpiredItems(region)...)
return append(res, cache.checkPeerFlow(region, peers, region.GetLoads(), region.GetInterval().GetEndTimestamp()-region.GetInterval().GetStartTimestamp())...)
return append(res, cache.checkPeerFlow(region, peers, region.GetLoads(), interval)...)
}

func updateFlow(cache *hotPeerCache, res []*HotPeerStat) []*HotPeerStat {
Expand Down
3 changes: 1 addition & 2 deletions tools/pd-ctl/tests/hot/hot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ func (suite *hotTestSuite) checkHot(cluster *pdTests.TestCluster) {
region := core.NewRegionInfo(&metapb.Region{
Id: hotRegionID,
}, leader)
interval := region.GetInterval()
hotStat.CheckReadAsync(statistics.NewCheckPeerTask(region, loads, interval.GetEndTimestamp()-interval.GetStartTimestamp()))
hotStat.CheckReadAsync(statistics.NewCheckPeerTask(region, loads, reportInterval))
testutil.Eventually(re, func() bool {
hotPeerStat := getHotPeerStat(utils.Read, hotRegionID, hotStoreID)
return hotPeerStat != nil
Expand Down

0 comments on commit 668ca97

Please sign in to comment.