-
Notifications
You must be signed in to change notification settings - Fork 728
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
Conversation
Signed-off-by: Zheng Xiangsheng <[email protected]>
// 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)) |
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.
Why?
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.
Add some description.
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.
When will PeerID
be set and when not set?
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.
It will not be set now, and the builder
code will be updated later to use this new logic.
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.
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 { |
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.
Do we still need to check if peer is nil
here?
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 GetXX
function of ProtoBuf
has its own nil
judgment.
// BoolToUint64 converts bool to uint64. | ||
func BoolToUint64(b bool) uint64 { | ||
if b { | ||
return 1 | ||
} | ||
return 0 | ||
} |
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.
What about adding a unit test here?
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 think this is just a conditional operator.
Signed-off-by: Zheng Xiangsheng <[email protected]>
Signed-off-by: Zheng Xiangsheng <[email protected]>
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.
LGTM
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.
LGTM
/merge |
/run-all-tests |
tikv#2919) Signed-off-by: Zheng Xiangsheng <[email protected]>
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?
ConfVerChanged
frombool
touint64
ConfVerChanged
behavior ofRemovePeer
:PeerID
is specified, ifPeer.Id
is changed, it is also regarded asConfVerChanged = 1
Check List
Tests
Release note