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

operator: change the return type of ConfVerChanged from bool to uint64 #2919

Merged
merged 4 commits into from
Sep 8, 2020

Conversation

HunDunDM
Copy link
Member

@HunDunDM HunDunDM commented Sep 7, 2020

Signed-off-by: Zheng Xiangsheng [email protected]

What problem does this PR solve?

This is a child PR of #2886

For details, please refer to #2860

What is changed and how it works?

  • change the return type of ConfVerChanged from bool to uint64
  • adjust the ConfVerChanged behavior of RemovePeer:
    • when PeerID is specified, if Peer.Id is changed, it is also regarded as ConfVerChanged = 1

Check List

Tests

  • Unit test

Release note

  • No release note

@HunDunDM HunDunDM mentioned this pull request Sep 7, 2020
37 tasks
@HunDunDM HunDunDM self-assigned this Sep 7, 2020
@HunDunDM HunDunDM added the component/schedule Scheduling logic. label Sep 7, 2020
// ConfVerChanged returns the delta value for version increased by this step.
func (rp RemovePeer) ConfVerChanged(region *core.RegionInfo) uint64 {
id := region.GetStorePeer(rp.FromStore).GetId()
return typeutil.BoolToUint64(id == 0 || (rp.PeerID != 0 && id != rp.PeerID))
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Add some description.

Copy link
Contributor

Choose a reason for hiding this comment

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

When will PeerID be set and when not set?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will not be set now, and the builder code will be updated later to use this new logic.

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.

Rest LGTM

}
return false
}

// CheckSafety checks if the step meets the safety properties.
func (pl PromoteLearner) CheckSafety(region *core.RegionInfo) error {
peer := region.GetStorePeer(pl.ToStore)
if peer == nil {
if peer.GetId() != pl.PeerID {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need to check if peer is nil here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The GetXX function of ProtoBuf has its own nil judgment.

Comment on lines +38 to +44
// BoolToUint64 converts bool to uint64.
func BoolToUint64(b bool) uint64 {
if b {
return 1
}
return 0
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What about adding a unit test here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is just a conditional operator.

Signed-off-by: Zheng Xiangsheng <[email protected]>
@HunDunDM HunDunDM changed the title operator: ConfVerChanged returns uint64 operator: change the return type of ConfVerChanged from bool to uint64 Sep 8, 2020
Signed-off-by: Zheng Xiangsheng <[email protected]>
@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 8, 2020
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 ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Sep 8, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 8, 2020
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.

LGTM

@ti-srebot ti-srebot added status/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Sep 8, 2020
@disksing
Copy link
Contributor

disksing commented Sep 8, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 8, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit cf644c1 into tikv:master Sep 8, 2020
@HunDunDM HunDunDM deleted the joint/steps-uint64 branch September 8, 2020 11:02
HunDunDM added a commit to HunDunDM/pd that referenced this pull request Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/schedule Scheduling logic. status/can-merge Indicates a PR has been approved by a committer. status/LGT3 The PR has already had 3 LGTM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants