Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

balance_region: remove unnecessary retry when pick region from a store. #5397

Open
AndreMouche opened this issue Aug 4, 2022 · 0 comments · May be fixed by #5398
Open

balance_region: remove unnecessary retry when pick region from a store. #5397

AndreMouche opened this issue Aug 4, 2022 · 0 comments · May be fixed by #5398
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@AndreMouche
Copy link
Member

Enhancement Task

In scheduler balance region, we try and retry to pick a region from a store until success with the following priority:

  • pending region
  • follower
  • leader
  • learner

for i := 0; i < retryLimit; i++ {
schedulerCounter.WithLabelValues(s.GetName(), "total").Inc()
// Priority pick the region that has a pending peer.
// Pending region may means the disk is overload, remove the pending region firstly.
plan.region = filter.SelectOneRegion(cluster.RandPendingRegions(plan.SourceStoreID(), s.conf.Ranges),
baseRegionFilters...)
if plan.region == nil {
// Then pick the region that has a follower in the source store.
plan.region = filter.SelectOneRegion(cluster.RandFollowerRegions(plan.SourceStoreID(), s.conf.Ranges),
append(baseRegionFilters, pendingFilter)...)
}
if plan.region == nil {
// Then pick the region has the leader in the source store.
plan.region = filter.SelectOneRegion(cluster.RandLeaderRegions(plan.SourceStoreID(), s.conf.Ranges),
append(baseRegionFilters, pendingFilter)...)
}
if plan.region == nil {
// Finally pick learner.
plan.region = filter.SelectOneRegion(cluster.RandLearnerRegions(plan.SourceStoreID(), s.conf.Ranges),
append(baseRegionFilters, pendingFilter)...)
}
if plan.region == nil {
schedulerCounter.WithLabelValues(s.GetName(), "no-region").Inc()
continue
}

However, I think if we failed to pick a region from pending regions, the possibility of successfully pick a region from the pending region is very very low, so could we skip to pick from pending in the next retry once we get no region from pending regions?

@AndreMouche AndreMouche added the type/enhancement The issue or PR belongs to an enhancement. label Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant