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

unsafe_recovery: also consider applied index when selects force leader #7920

Merged
merged 7 commits into from
Apr 7, 2024

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Mar 14, 2024

What problem does this PR solve?

Issue Number: close #7919, ref tikv/tikv#16717

What is changed and how does it work?

Change online recovery region stale comparator to select to the peer with maximum last index or applied index to become leader.

Check List

Tests

  • Unit test

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

Copy link
Contributor

ti-chi-bot bot commented Mar 14, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Connor1996
  • 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 bot added the release-note-none Denotes a PR that doesn't merit a release note. label Mar 14, 2024
@ti-chi-bot ti-chi-bot bot requested review from HunDunDM and nolouch March 14, 2024 08:06
@ti-chi-bot ti-chi-bot bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 14, 2024
@glorv
Copy link
Contributor Author

glorv commented Mar 14, 2024

/cc @nolouch @Connor1996 PTAL

@ti-chi-bot ti-chi-bot bot requested a review from Connor1996 March 14, 2024 08:06
Copy link
Contributor

ti-chi-bot bot commented Mar 14, 2024

@glorv: GitHub didn't allow me to request PR reviews from the following users: PTAL.

Note that only tikv members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @nolouch @Connor1996 PTAL

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.

@glorv glorv changed the title Unsafe recovery unsafe_recovery: also consider applied index when selects leader Mar 14, 2024
@glorv glorv changed the title unsafe_recovery: also consider applied index when selects leader unsafe_recovery: also consider applied index when selects force leader Mar 14, 2024
Signed-off-by: glorv <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 3, 2024
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 3, 2024
@rleungx
Copy link
Member

rleungx commented Apr 3, 2024

Need to update go mod.

maxIdxA := typeutil.MaxUint64(a.report.GetRaftState().GetLastIndex(), a.report.AppliedIndex)
maxIdxB := typeutil.MaxUint64(b.report.GetRaftState().GetLastIndex(), b.report.AppliedIndex)
return int(maxIdxA - maxIdxB)
},
func(a, b *regionItem) int {
return int(a.report.GetRaftState().GetLastIndex()) - int(b.report.GetRaftState().GetLastIndex())
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to compare the last index again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if max(applied_index) == max(last_index), we better choose the max(last_index) peer to avoid doing force compact.

Signed-off-by: glorv <[email protected]>
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Merging #7920 (172ba3b) into master (a173a08) will increase coverage by 0.09%.
The diff coverage is 100.00%.

❗ Current head 172ba3b differs from pull request most recent head 512a659. Consider uploading reports for the commit 512a659 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7920      +/-   ##
==========================================
+ Coverage   73.49%   73.59%   +0.09%     
==========================================
  Files         436      436              
  Lines       48525    48529       +4     
==========================================
+ Hits        35665    35715      +50     
+ Misses       9802     9757      -45     
+ Partials     3058     3057       -1     
Flag Coverage Δ
unittests 73.59% <100.00%> (+0.09%) ⬆️

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

@glorv
Copy link
Contributor Author

glorv commented Apr 3, 2024

@Connor1996 PTAL again, thanks~

Copy link
Member

@Connor1996 Connor1996 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 bot removed the status/LGT1 Indicates that a PR has LGTM 1. label Apr 7, 2024
@ti-chi-bot ti-chi-bot bot added the status/LGT2 Indicates that a PR has LGTM 2. label Apr 7, 2024
@Connor1996
Copy link
Member

/merge

Copy link
Contributor

ti-chi-bot bot commented Apr 7, 2024

@Connor1996: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and 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.

If you have any questions about the PR merge process, please refer to pr process.

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.

Copy link
Contributor

ti-chi-bot bot commented Apr 7, 2024

This pull request has been accepted and is ready to merge.

Commit hash: 172ba3b

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 7, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 7, 2024

@glorv: 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 bot merged commit 569f3e0 into tikv:master Apr 7, 2024
22 checks passed
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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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.

Consider applied index in unsafe recovery
3 participants