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

fit: optimize the selection of witness rule candidates #5904

Merged
merged 5 commits into from
Feb 8, 2023

Conversation

ethercflow
Copy link
Member

@ethercflow ethercflow commented Feb 3, 2023

ref #5568

Signed-off-by: Wenbo Zhang [email protected]

What problem does this PR solve?

Issue Number: ref #5568

What is changed and how does it work?

  1. If the IsWitness of the Rule is true, the leader will be removed from the candidate list, so that when the best rule is selected, it is impossible for the leader to exist in the witness rule;
  2. When sorting the candidate peers, if the two peers participating in the comparison belong to the same storestate, then 50% of them will be randomly sorted to prevent the sorted peer list from being fixed, so that when the best rule is selected, the fixed peer will always be returned, causing some store balance, a store is 0;

before:

img_v2_b7ccd415-efc8-431d-a11f-7c77ee78430g

After:

a325ce27-abb7-43b2-949f-1764ccad3219

Update:
If the rule remains unchanged, each time the rule_checker checks the region, it will directly fetch the previously calculated best rule from the cache without being randomly affected. But If the rule is manually modified, the cache will become invalid, and the rule_checker will recalculate each region, which may cause unnecessary scheduling for existing peers, such as adding TiFlash. So remove the random strategy.


Check List

Tests

  • None

Code changes

  • None

Side effects

  • None

Related changes

  • None

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 3, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bufferflies
  • rleungx

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 submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Feb 3, 2023
@wuhuizuo
Copy link
Contributor

wuhuizuo commented Feb 6, 2023

/test build

1 similar comment
@wuhuizuo
Copy link
Contributor

wuhuizuo commented Feb 6, 2023

/test build

ref tikv#5568

Signed-off-by: Wenbo Zhang <[email protected]>
@ethercflow
Copy link
Member Author

Random might cause some test cases to fail, I'll think again (:

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Base: 75.46% // Head: 75.49% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (73d253a) compared to base (03081c6).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 73d253a differs from pull request most recent head cb30f33. Consider uploading reports for the commit cb30f33 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5904      +/-   ##
==========================================
+ Coverage   75.46%   75.49%   +0.02%     
==========================================
  Files         345      345              
  Lines       35132    35126       -6     
==========================================
+ Hits        26514    26517       +3     
+ Misses       6322     6319       -3     
+ Partials     2296     2290       -6     
Flag Coverage Δ
unittests 75.49% <100.00%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
server/schedule/placement/fit.go 95.83% <100.00%> (ø)
pkg/errs/errs.go 75.00% <0.00%> (-25.00%) ⬇️
pkg/utils/tempurl/tempurl.go 45.00% <0.00%> (-15.00%) ⬇️
pkg/id/id.go 83.05% <0.00%> (-3.39%) ⬇️
pkg/member/member.go 64.21% <0.00%> (-1.58%) ⬇️
server/region_syncer/client.go 86.56% <0.00%> (-1.50%) ⬇️
tools/pd-ctl/pdctl/command/operator.go 66.66% <0.00%> (-1.15%) ⬇️
server/region_syncer/server.go 81.86% <0.00%> (-1.10%) ⬇️
server/cluster/coordinator.go 71.59% <0.00%> (-0.76%) ⬇️
pkg/tso/tso.go 70.22% <0.00%> (-0.57%) ⬇️
... and 18 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Wenbo Zhang <[email protected]>
@ethercflow ethercflow requested review from rleungx and removed request for disksing February 7, 2023 09:58
@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 Feb 8, 2023
@bufferflies
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

@bufferflies: 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: 73d253a

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

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

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 ti-chi-bot merged commit efa3e31 into tikv:master Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. 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.

5 participants