diff --git a/server/schedulers/utils.go b/server/schedulers/utils.go index 86498d1c623b..8fc5f9699a54 100644 --- a/server/schedulers/utils.go +++ b/server/schedulers/utils.go @@ -401,8 +401,10 @@ func (s *storeInfo) addInfluence(infl *Influence, w float64) { return } if s.PendingSum == nil { - s.PendingSum = new(Influence) - s.PendingSum.Loads = make([]float64, len(infl.Loads)) + s.PendingSum = &Influence{ + Loads: make([]float64, len(infl.Loads)), + Count: 0, + } } for i, load := range infl.Loads { s.PendingSum.Loads[i] += load * w @@ -514,12 +516,6 @@ func summaryStoresLoad( } loads[statistics.QueryDim] = storeLoads[statistics.StoreWriteQuery] } - if !isTiFlash { - // The TiFlash flow is isolated from TiKV, so it is not counted in the sum. - for i := range allLoadSum { - allLoadSum[i] += loads[i] - } - } // Find all hot peers first var hotPeers []*statistics.HotPeerStat @@ -554,6 +550,13 @@ func summaryStoresLoad( hotPeerSummary.WithLabelValues(ty, fmt.Sprintf("%v", id)).Set(peerLoadSum[statistics.QueryDim]) } } + + if !isTiFlash { + // The TiFlash flow is isolated from TiKV, so it is not counted in the sum. + for i := range allLoadSum { + allLoadSum[i] += loads[i] + } + } allCount += float64(len(hotPeers)) // Build store load prediction from current load and pending influence.