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

placement: improve regoin fit #2639

Merged
merged 9 commits into from
Jul 16, 2020
Merged

placement: improve regoin fit #2639

merged 9 commits into from
Jul 16, 2020

Conversation

disksing
Copy link
Contributor

What problem does this PR solve?

When we fit region's peers into rules, we check rules one by one, and for each one, we pick the best option (if there are multiple best options we simply pick the first one). The problem is that the current choice will affect subsequent rules, so the current optimal option is not necessarily the global optimal option.

For example, a region has 4 peers: [host=h1, host=h2, host=h3, host=h4], and it matches 2 rules: 3 voters + 1 voter on h2. The best choice is [host=h1, host=h3, host=h4] goes to the first rule and [host=h2] goes to the second rule. Without consider globally, the first rule may pick [host=h1, host=h2, host=h3] and left [host=h4] which is not suitable for the second rule.

The problem is originally brought up from #2626

What is changed and how it works?

Recursive all options to choose the global best.

Check List

Tests

  • Unit test

Release note

  • Fix the issue that when enabling placement rules, sometimes region replicas cannot schedule to optimal

@disksing disksing added type/bugfix This PR fixes a bug. component/placement Placement rule. labels Jul 14, 2020
@disksing disksing requested review from JmPotato, Yisaer and HunDunDM July 14, 2020 08:26
@disksing disksing added this to the v4.0.4 milestone Jul 15, 2020
Signed-off-by: disksing <[email protected]>
@Yisaer
Copy link
Contributor

Yisaer commented Jul 16, 2020

I test a case with

"1111,1221,1331,1241", []string{"3/voter/host=host1+host2+host3+host4/rack,host", "1/voter/host=host3/"

The result is that "1111,1221,1331" fit the first rule and no peer fits the second rule. Is the result expected?

@disksing
Copy link
Contributor Author

I test a case with

"1111,1221,1331,1241", []string{"3/voter/host=host1+host2+host3+host4/rack,host", "1/voter/host=host3/"

The result is that "1111,1221,1331" fit the first rule and no peer fits the second rule. Is the result expected?

It is expedted. for rule1, 1111,1221,1331 is better than 1111,1221,1241.

It is the same situation with my test case {"1111,2211,3111,3112", []string{"3/voter//zone", "1/voter/rack=rack2/"}, "1111,2211,3111//3112"}.

Copy link
Contributor

@Yisaer Yisaer left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying. LGTM

@ti-srebot
Copy link
Contributor

@Yisaer,Thanks for your review. However, LGTM is restricted to Reviewers or higher roles.See the corresponding SIG page for more information. Related SIGs: scheduling(slack).

Copy link
Member

@JmPotato JmPotato 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-srebot
Copy link
Contributor

@JmPotato,Thanks for your review. However, LGTM is restricted to Reviewers or higher roles.See the corresponding SIG page for more information. Related SIGs: scheduling(slack).

@disksing
Copy link
Contributor Author

/run-all-tests

@disksing
Copy link
Contributor Author

/run-integration-ddl-test

@disksing disksing merged commit 764cbce into tikv:master Jul 16, 2020
@disksing disksing deleted the fit branch July 16, 2020 09:54
@disksing disksing modified the milestones: v4.0.4, v4.0.5 Jul 28, 2020
@rleungx rleungx removed this from the v4.0.5 milestone Aug 4, 2020
@rleungx rleungx added the needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. label Aug 4, 2020
@rleungx
Copy link
Member

rleungx commented Aug 4, 2020

/run-cherry-picker

ti-srebot pushed a commit to ti-srebot/pd that referenced this pull request Aug 4, 2020
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #2720

ti-srebot added a commit that referenced this pull request Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/placement Placement rule. needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants