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

scheduler: do not balance the empty regions #3344

Merged
merged 5 commits into from
Jan 20, 2021

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Jan 7, 2021

What problem does this PR solve?

After drop table or such kind of operation, there might be a large number of empty regions which cannot be merged immediately. The balance region scheduler will balance them if the stores' size have the difference. In this case, it may cause a lot of balance operation which affect the performance.

What is changed and how it works?

This PR will skip the empty region when selecting the region.

Check List

Tests

  • Unit test

Release note

@rleungx rleungx added the component/scheduler Scheduler logic. label Jan 7, 2021
@ti-chi-bot ti-chi-bot requested review from disksing and Yisaer January 7, 2021 06:14
@codecov
Copy link

codecov bot commented Jan 7, 2021

Codecov Report

Merging #3344 (27051be) into master (02c5f77) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3344      +/-   ##
==========================================
- Coverage   74.94%   74.91%   -0.04%     
==========================================
  Files         243      243              
  Lines       23245    23250       +5     
==========================================
- Hits        17421    17417       -4     
- Misses       4259     4265       +6     
- Partials     1565     1568       +3     
Flag Coverage Δ
unittests 74.91% <100.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/mock/mockcluster/mockcluster.go 94.41% <100.00%> (+0.93%) ⬆️
server/schedule/opt/healthy.go 100.00% <100.00%> (ø)
server/schedulers/balance_region.go 86.20% <100.00%> (ø)
server/region_syncer/server.go 83.20% <0.00%> (-6.11%) ⬇️
server/id/id.go 76.19% <0.00%> (-4.77%) ⬇️
server/election/lease.go 94.91% <0.00%> (-1.70%) ⬇️
server/schedule/operator/step.go 67.44% <0.00%> (-1.67%) ⬇️
server/cluster/coordinator.go 73.57% <0.00%> (-0.72%) ⬇️
server/grpc_service.go 56.76% <0.00%> (-0.67%) ⬇️
server/handler.go 42.75% <0.00%> (-0.50%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02c5f77...27051be. Read the comment docs.

@rleungx rleungx added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jan 7, 2021
@@ -167,6 +171,13 @@ func (s *balanceRegionScheduler) Schedule(cluster opt.Cluster) []*operator.Opera
}
log.Debug("select region", zap.String("scheduler", s.GetName()), zap.Uint64("region-id", region.GetID()))

// Skip the empty region
if region.GetApproximateSize() <= core.EmptyRegionApproximateSize && regionCount > balanceEmptyRegionThreshold {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems better to define a region filter and filter empty regions in Rand{Pending, Follower, Leader, Learner}Region.

Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: rleungx <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Copy link
Member

@HunDunDM HunDunDM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest LGTM

server/schedule/opt/healthy.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 19, 2021
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 19, 2021
Signed-off-by: Ryan Leung <rleungx@gmail.com>
@disksing
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

@disksing: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 5219763

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 20, 2021
@ti-chi-bot
Copy link
Member

@rleungx: Your PR has out-of-dated, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/scheduler Scheduler logic. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants