-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: merge the rules if the constraints are the same #46529
Conversation
b06a3ef
to
e43738c
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #46529 +/- ##
================================================
- Coverage 73.3326% 72.8193% -0.5134%
================================================
Files 1322 1361 +39
Lines 396474 407518 +11044
================================================
+ Hits 290745 296752 +6007
- Misses 87208 92033 +4825
- Partials 18521 18733 +212
Flags with carried forward coverage won't be shown. Click here to find out more.
|
e43738c
to
f9564a1
Compare
Signed-off-by: nolouch <nolouch@gmail.com>
f9564a1
to
d8bcc2a
Compare
Signed-off-by: nolouch <nolouch@gmail.com>
/retest-required |
/retest-required |
/retest-required |
cd2792e
to
7bdae4f
Compare
ddl/placement/constraints.go
Outdated
func (constraints Constraints) FingerPrint() string { | ||
copied := make(Constraints, len(constraints)) | ||
copy(copied, constraints) | ||
sort.SliceStable(copied, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slices.SortStableFunction is better. it can remove BCE.
PTAL @CabinfeverB @JmPotato |
/test unit-test |
@nolouch: The specified target(s) for
Use In response to this:
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 kubernetes/test-infra repository. |
} | ||
} | ||
if leaderGroup != nil && canBecameLeaderNum == 1 { | ||
leaderGroup.MergeTransformableRoles() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some comments here or somewhere to explain why when two or more groups have a leader or voter role, we should skip MergeTransformableRoles
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. But if 1 leader and 2 followers in group1 and 2 voters in group2, can we merge group1 to voters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. But if 1 leader and 2 followers in group1 and 2 voters in group2, can we merge group1 to voters?
No. They don't share same constraints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. But if 1 leader and 2 followers in group1 and 2 voters in group2, can we merge group1 to voters?
that means the group 1
has leader priority than group 2, so it's not transformable. I added comments.
// One Bundle is from one PlacementSettings, rule share same location labels, so we can use the first rule's location labels. | ||
var locationLabels []string | ||
tempRules := b.Rules[:0] | ||
id := 0 | ||
for _, rule := range b.Rules { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some extra checks for rules in Tidy? I think Tidy
can only be called when some fields are empty (StartKeyHex/EndKeyHex
.etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some extra checks for rules in Tidy? I think
Tidy
can only be called when some fields are empty (StartKeyHex/EndKeyHex
.etc).
Does it mean Bundle is not associated with a table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the comments saied, it's optimized rules, try to simplify the rules.
// One Bundle is from one PlacementSettings, rule share same location labels, so we can use the first rule's location labels. | ||
var locationLabels []string | ||
tempRules := b.Rules[:0] | ||
id := 0 | ||
for _, rule := range b.Rules { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some extra checks for rules in Tidy? I think
Tidy
can only be called when some fields are empty (StartKeyHex/EndKeyHex
.etc).
Does it mean Bundle is not associated with a table?
ddl/placement/bundle.go
Outdated
if len(c.rules) == 0 { | ||
return | ||
} | ||
newRules := make([]*Rule, 0, len(c.rules)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The maximum length is 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe more.
} | ||
} | ||
if leaderGroup != nil && canBecameLeaderNum == 1 { | ||
leaderGroup.MergeTransformableRoles() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. But if 1 leader and 2 followers in group1 and 2 voters in group2, can we merge group1 to voters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I have a question: as PR description, the cause of multiple rules is multiple tables instead of role?
it is caused by multi-role setting. see Lines 57 to 135 in 2472154
|
PTAL @lcwangchao @xhebox @CabinfeverB thanks. |
/test unit-test |
@CabinfeverB: The specified target(s) for
Use In response to this:
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 kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CabinfeverB, xhebox The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/test unit-test |
@nolouch: The specified target(s) for
Use In response to this:
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 kubernetes/test-infra repository. |
…ingcap#46529)" This reverts commit 4cc6c18.
What problem does this PR solve?
Issue Number: close #45395
Problem Summary:
The rules in PD side:
There is no need to split into two rules because we do not need to distinguish roles, two rules perhaps exist some problems. such as
location-labels
may not work in tikv/pd#6637What is changed and how it works?
Check List
Tests
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.