From 8ee18a4b498669d0a23067e643e5fcfbfc521803 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Tue, 30 Apr 2024 11:46:57 +0800 Subject: [PATCH] pkg: fix `RegionStatsNeedUpdate` condition (#8133) ref tikv/pd#7897 Signed-off-by: Ryan Leung Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- pkg/statistics/region_collection.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/statistics/region_collection.go b/pkg/statistics/region_collection.go index cb0de6f601b..565597b4efb 100644 --- a/pkg/statistics/region_collection.go +++ b/pkg/statistics/region_collection.go @@ -158,14 +158,14 @@ func (r *RegionStatistics) RegionStatsNeedUpdate(region *core.RegionInfo) bool { region.IsOversized(int64(r.conf.GetRegionMaxSize()), int64(r.conf.GetRegionMaxKeys())) { return true } - // expected to be zero for below type - if r.IsRegionStatsType(regionID, PendingPeer) && len(region.GetPendingPeers()) == 0 { + + if r.IsRegionStatsType(regionID, PendingPeer) != (len(region.GetPendingPeers()) != 0) { return true } - if r.IsRegionStatsType(regionID, DownPeer) && len(region.GetDownPeers()) == 0 { + if r.IsRegionStatsType(regionID, DownPeer) != (len(region.GetDownPeers()) != 0) { return true } - if r.IsRegionStatsType(regionID, LearnerPeer) && len(region.GetLearners()) == 0 { + if r.IsRegionStatsType(regionID, LearnerPeer) != (len(region.GetLearners()) != 0) { return true }