diff --git a/server/schedule/placement/fit.go b/server/schedule/placement/fit.go index 5556ec24fe6..8f35d30862c 100644 --- a/server/schedule/placement/fit.go +++ b/server/schedule/placement/fit.go @@ -59,6 +59,9 @@ func (f *RegionFit) GetRuleFit(peerID uint64) *RuleFit { // It returns 1 when the first fit result is better. func CompareRegionFit(a, b *RegionFit) int { for i := range a.RuleFits { + if i >= len(b.RuleFits) { + break + } if cmp := compareRuleFit(a.RuleFits[i], b.RuleFits[i]); cmp != 0 { return cmp }