Skip to content

Commit

Permalink
scheduler: add more nil-check code in adjacent_region
Browse files Browse the repository at this point in the history
related pr is tikv#1250
  • Loading branch information
nanne007 committed Jan 2, 2019
1 parent 38221ce commit b09982b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/schedulers/adjacent_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ func (l *balanceAdjacentRegionScheduler) disperseLeader(cluster schedule.Cluster
}
storesInfo := make([]*core.StoreInfo, 0, len(diffPeers))
for _, p := range diffPeers {
storesInfo = append(storesInfo, cluster.GetStore(p.GetStoreId()))
if store := cluster.GetStore(p.GetStoreId()); store != nil {
storesInfo = append(storesInfo, store)
}
}
target := l.selector.SelectTarget(cluster, storesInfo)
if target == nil {
Expand All @@ -279,6 +281,10 @@ func (l *balanceAdjacentRegionScheduler) dispersePeer(cluster schedule.Cluster,
leaderStoreID := region.GetLeader().GetStoreId()
stores := cluster.GetRegionStores(region)
source := cluster.GetStore(leaderStoreID)
if source == nil {
return nil
}

scoreGuard := schedule.NewDistinctScoreFilter(cluster.GetLocationLabels(), stores, source)
excludeStores := region.GetStoreIds()
for _, storeID := range l.cacheRegions.assignedStoreIds {
Expand Down

0 comments on commit b09982b

Please sign in to comment.