Skip to content

Commit

Permalink
*: check whether region is nil (tikv#7263)
Browse files Browse the repository at this point in the history
close tikv#7261

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
lhy1024 and ti-chi-bot[bot] authored Oct 26, 2023
1 parent bfc988b commit 4549e23
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/schedule/schedulers/hot_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,9 @@ func (bs *balanceSolver) tryAddPendingInfluence() bool {
dstStoreID := uint64(0)
if isSplit {
region := bs.GetRegion(bs.ops[0].RegionID())
if region == nil {
return false
}
for id := range region.GetStoreIDs() {
srcStoreIDs = append(srcStoreIDs, id)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/schedule/schedulers/split_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,17 @@ func (s *splitBucketScheduler) splitBucket(plan *splitBucketPlan) []*operator.Op
}
if splitBucket != nil {
region := plan.cluster.GetRegion(splitBucket.RegionID)
if region == nil {
return nil
}
splitKey := make([][]byte, 0)
if bytes.Compare(region.GetStartKey(), splitBucket.StartKey) < 0 {
splitKey = append(splitKey, splitBucket.StartKey)
}
if bytes.Compare(region.GetEndKey(), splitBucket.EndKey) > 0 {
splitKey = append(splitKey, splitBucket.EndKey)
}
op, err := operator.CreateSplitRegionOperator(SplitBucketType, plan.cluster.GetRegion(splitBucket.RegionID), operator.OpSplit,
op, err := operator.CreateSplitRegionOperator(SplitBucketType, region, operator.OpSplit,
pdpb.CheckPolicy_USEKEY, splitKey)
if err != nil {
splitBucketCreateOpeartorFailCounter.Inc()
Expand Down
6 changes: 5 additions & 1 deletion pkg/statistics/region_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ func (r *RegionStatistics) GetRegionStatsByType(typ RegionStatisticType) []*core
defer r.RUnlock()
res := make([]*core.RegionInfo, 0, len(r.stats[typ]))
for regionID := range r.stats[typ] {
res = append(res, r.rip.GetRegion(regionID).Clone())
region := r.rip.GetRegion(regionID)
if region == nil {
continue
}
res = append(res, region.Clone())
}
return res
}
Expand Down

0 comments on commit 4549e23

Please sign in to comment.