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: fix some error checks #5629

Merged
merged 4 commits into from Oct 26, 2022
Merged

Conversation

HunDunDM
Copy link
Member

What problem does this PR solve?

Issue Number: Close #5623

What is changed and how does it work?

  • Improve checks of PromoteLearner and DemoteVoter
  • Allow to directly promote or demote in ChangePeerV2Enter.

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

  • Since this issue just results in incorrect logging, this PR is not cherry-picked.

Release note

None

Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Oct 24, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lhy1024
  • nolouch

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.

@@ -406,7 +406,7 @@ type PromoteLearner struct {
// ConfVerChanged returns the delta value for version increased by this step.
func (pl PromoteLearner) ConfVerChanged(region *core.RegionInfo) uint64 {
peer := region.GetStoreVoter(pl.ToStore)
return typeutil.BoolToUint64(peer.GetId() == pl.PeerID)
return typeutil.BoolToUint64(peer.GetId() == pl.PeerID && peer.GetRole() == metapb.PeerRole_Voter)
Copy link
Member Author

@HunDunDM HunDunDM Oct 24, 2022

Choose a reason for hiding this comment

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

Currently, IncomingVoter and DemotingVoter are also considered Voter, so additional checks are required.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should add these comments to code, which is convenient to read code.

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 comment

func (dv DemoteVoter) ConfVerChanged(region *core.RegionInfo) bool {
peer := region.GetStoreLearner(dv.ToStore)
return peer.GetId() == dv.PeerID
func (dv DemoteVoter) ConfVerChanged(region *core.RegionInfo) uint64 {
Copy link
Member Author

Choose a reason for hiding this comment

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

ConfVerChanged will be called when the next steps are performed, and it is necessary to consider that the Peer may have been removed in the future.

@@ -700,7 +701,8 @@ func (cpe ChangePeerV2Enter) ConfVerChanged(region *core.RegionInfo) uint64 {
}
}
for _, dv := range cpe.DemoteVoters {
peer := region.GetStoreVoter(dv.ToStore)
peer := region.GetStorePeer(dv.ToStore)
Copy link
Member Author

Choose a reason for hiding this comment

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

There may be Learner here, the previous GetStoreVoter was used incorrectly.

@@ -715,16 +717,16 @@ func (cpe ChangePeerV2Enter) IsFinish(region *core.RegionInfo) bool {
if peer != nil && peer.GetId() != pl.PeerID {
log.Warn("obtain unexpected peer", zap.String("expect", pl.String()), zap.Uint64("obtain-voter", peer.GetId()))
}
if peer.GetId() != pl.PeerID || peer.GetRole() != metapb.PeerRole_IncomingVoter {
if peer.GetId() != pl.PeerID || !core.IsVoterOrIncomingVoter(peer) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Allow to promote directly.

@@ -740,12 +742,10 @@ func (cpe ChangePeerV2Enter) CheckInProgress(_ ClusterInformer, region *core.Reg
return errors.New("peer does not exist")
}
switch peer.GetRole() {
case metapb.PeerRole_Learner:
case metapb.PeerRole_Learner, metapb.PeerRole_Voter:
Copy link
Member Author

Choose a reason for hiding this comment

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

Allow to promote directly.

@codecov
Copy link

codecov bot commented Oct 24, 2022

Codecov Report

Base: 75.76% // Head: 75.65% // Decreases project coverage by -0.11% ⚠️

Coverage data is based on head (d95c36d) compared to base (2b51932).
Patch coverage: 100.00% of modified lines in pull request are covered.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5629      +/-   ##
==========================================
- Coverage   75.76%   75.65%   -0.12%     
==========================================
  Files         326      326              
  Lines       32386    32362      -24     
==========================================
- Hits        24538    24484      -54     
- Misses       5746     5770      +24     
- Partials     2102     2108       +6     
Flag Coverage Δ
unittests 75.65% <100.00%> (-0.12%) ⬇️

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

Impacted Files Coverage Δ
server/schedule/operator/step.go 74.48% <100.00%> (+1.23%) ⬆️
pkg/dashboard/keyvisual/input/core.go 0.00% <0.00%> (-33.34%) ⬇️
pkg/tempurl/tempurl.go 60.00% <0.00%> (-10.00%) ⬇️
server/schedulers/shuffle_hot_region.go 56.00% <0.00%> (-10.00%) ⬇️
server/id/id.go 89.83% <0.00%> (-6.78%) ⬇️
pkg/dashboard/adapter/manager.go 77.01% <0.00%> (-4.60%) ⬇️
server/server.go 74.43% <0.00%> (-1.78%) ⬇️
server/region_syncer/client.go 85.07% <0.00%> (-1.50%) ⬇️
pkg/btree/btree.go 86.26% <0.00%> (-0.97%) ⬇️
server/schedule/operator_controller.go 86.26% <0.00%> (-0.91%) ⬇️
... and 25 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.

@HunDunDM HunDunDM removed the request for review from disksing October 24, 2022 08:08
Signed-off-by: HunDunDM <hundundm@gmail.com>
Copy link
Contributor

@nolouch nolouch 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-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 26, 2022
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

Does it will impact the simulator?

@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 Oct 26, 2022
@nolouch
Copy link
Contributor

nolouch commented Oct 26, 2022

/merge

@ti-chi-bot
Copy link
Member

@nolouch: 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: d032e0b

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

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

At the same time I will also trigger all tests for you:

/run-all-tests

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.

@HunDunDM
Copy link
Member Author

Does it will impact the simulator?

does not affect

@ti-chi-bot ti-chi-bot merged commit 914e19c into tikv:master Oct 26, 2022
@HunDunDM HunDunDM deleted the single-demote branch November 7, 2022 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none 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.

Certain properly executed schedules print error logs
4 participants