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

schedule: revise region_scatter distribution for multi groups #3422

Merged
merged 17 commits into from
Apr 21, 2021

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented Feb 18, 2021

Signed-off-by: Song Gao [email protected]

What problem does this PR solve?

ref pingcap/tidb#22788

Currently region-scatter didn't work well for multi regions in different groups.

For example, there are 50 regions and 6 stores in the cluster. Each region belong to a dedicated group.

region scatter may locate them in the store1/store2/store3. Thus from each region in the group, the distribution is well. And for the whole cluster, the distribution is not well.

What is changed and how it works?

During region scatter, we should consider whether the target store already have the most peer or leader, if it is, we should skip it.

Check List

Tests

  • Unit test

I also tested with the testcases in this document: https://docs.google.com/document/d/1cGZU2DCm0UuIueqAQP8TGqTivyavCvB_QiwIzqvP_rA/edit

All the test case results didn't change.

Release note

  • No release note

@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 18, 2021
Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
@codecov
Copy link

codecov bot commented Feb 18, 2021

Codecov Report

Merging #3422 (3eb838b) into master (f204416) will decrease coverage by 0.18%.
The diff coverage is 94.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3422      +/-   ##
==========================================
- Coverage   74.75%   74.57%   -0.19%     
==========================================
  Files         245      245              
  Lines       24107    24136      +29     
==========================================
- Hits        18022    17999      -23     
- Misses       4480     4516      +36     
- Partials     1605     1621      +16     
Flag Coverage Δ
unittests 74.57% <94.28%> (-0.19%) ⬇️

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

Impacted Files Coverage Δ
server/schedule/operator/builder.go 87.98% <ø> (ø)
server/schedule/region_scatterer.go 88.37% <92.85%> (+1.32%) ⬆️
pkg/cache/ttl.go 97.77% <100.00%> (+0.15%) ⬆️
server/schedule/operator/create_operator.go 89.76% <100.00%> (+0.08%) ⬆️
server/id/id.go 76.19% <0.00%> (-4.77%) ⬇️
server/tso/allocator_manager.go 73.92% <0.00%> (-3.99%) ⬇️
server/schedulers/random_merge.go 60.00% <0.00%> (-3.34%) ⬇️
server/member/member.go 65.59% <0.00%> (-2.69%) ⬇️
client/base_client.go 83.24% <0.00%> (-2.17%) ⬇️
server/server.go 71.42% <0.00%> (-2.16%) ⬇️
... and 6 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 f204416...3eb838b. Read the comment docs.

@Yisaer Yisaer marked this pull request as ready for review February 19, 2021 04:48
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 19, 2021
@lhy1024 lhy1024 self-requested a review February 19, 2021 08:39
@HunDunDM HunDunDM added the component/cluster Cluster logic. label Feb 20, 2021
@Yisaer Yisaer requested a review from disksing February 23, 2021 08:40
Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
@nolouch
Copy link
Contributor

nolouch commented Feb 25, 2021

What might become worse if there is concurrency? I remember that there was a situation where there was a concurrent split of different tables.

targetPeers[peer.GetStoreId()] = peer
continue
storeCount := context.selectedPeer.storeTotalCount(peer.GetStoreId())
if storeCount < maxStoreTotalCount || storeCount == minStoreTotalCount {
Copy link
Member

Choose a reason for hiding this comment

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

What is the difference between storeCount < maxStoreTotalCount and storeCount == minStoreTotalCount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the storeCounts are all the same( maxStoreTotalCount == minStoreTotalCount), we can pick this store as candidate.

@Yisaer Yisaer marked this pull request as draft March 5, 2021 03:20
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 5, 2021
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 14, 2021
@Yisaer Yisaer closed this Mar 17, 2021
@Yisaer Yisaer reopened this Mar 17, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 1, 2021
@Yisaer Yisaer marked this pull request as ready for review April 1, 2021 05:22
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 1, 2021
@Yisaer
Copy link
Contributor Author

Yisaer commented Apr 1, 2021

/run-all-tests

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • nolouch

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@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 Apr 21, 2021
@nolouch
Copy link
Contributor

nolouch commented Apr 21, 2021

/merge

@ti-chi-bot
Copy link
Member

@nolouch: 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: e91faed

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

@Yisaer: Your PR was out of date, I have automatically updated it for you.

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

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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

Merge canceled because a new commit is pushed.

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Apr 21, 2021
Signed-off-by: yisaer <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Apr 21, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Yisaer Yisaer added the status/can-merge Indicates a PR has been approved by a committer. label Apr 21, 2021
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Apr 21, 2021
@Yisaer Yisaer merged commit 9e60f4d into tikv:master Apr 21, 2021
ti-srebot pushed a commit to ti-srebot/pd that referenced this pull request Apr 21, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #3620

ti-srebot pushed a commit to ti-srebot/pd that referenced this pull request Apr 21, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #3621

Yisaer added a commit that referenced this pull request May 10, 2021
…#3620)

* cherry pick #3422 to release-4.0

Signed-off-by: ti-srebot <[email protected]>

* fix conflict

Signed-off-by: yisaer <[email protected]>

* remove test

Signed-off-by: yisaer <[email protected]>

* remove test

Signed-off-by: yisaer <[email protected]>

Co-authored-by: Song Gao <[email protected]>
ti-chi-bot added a commit that referenced this pull request May 28, 2021
ti-chi-bot bot added a commit that referenced this pull request Sep 1, 2023
close #6962

In past, PD conside peer distribution in the different group influenece by using `TotalCountByStore` , but not include the leader distribution. The max used situation is partition table. 
After this pr, TIDB call scatter api will use same group not different. 

ref:
#3422
pingcap/tidb#46156

Signed-off-by: bufferflies <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
ti-chi-bot bot added a commit that referenced this pull request Sep 11, 2023
close #6962

In past, PD conside peer distribution in the different group influenece by using `TotalCountByStore` , but not include the leader distribution. The max used situation is partition table. 
After this pr, TIDB call scatter api will use same group not different. 

ref:
#3422
pingcap/tidb#46156

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: bufferflies <[email protected]>

Co-authored-by: buffer <[email protected]>
Co-authored-by: bufferflies <[email protected]>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
ti-chi-bot bot added a commit that referenced this pull request Sep 28, 2023
close #6962

In past, PD conside peer distribution in the different group influenece by using `TotalCountByStore` , but not include the leader distribution. The max used situation is partition table. 
After this pr, TIDB call scatter api will use same group not different. 

ref:
#3422
pingcap/tidb#46156

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: bufferflies <[email protected]>

Co-authored-by: buffer <[email protected]>
Co-authored-by: bufferflies <[email protected]>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
ti-chi-bot bot added a commit that referenced this pull request Nov 22, 2023
close #6962

In past, PD conside peer distribution in the different group influenece by using `TotalCountByStore` , but not include the leader distribution. The max used situation is partition table. 
After this pr, TIDB call scatter api will use same group not different. 

ref:
#3422
pingcap/tidb#46156

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: bufferflies <[email protected]>

Co-authored-by: buffer <[email protected]>
Co-authored-by: bufferflies <[email protected]>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/cluster Cluster logic. needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. needs-cherry-pick-release-5.0 The PR needs to cherry pick to release-5.0 branch. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants