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

raftstore: introduce a precheck process before snapshot generation #17019

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

hbisheng
Copy link
Contributor

@hbisheng hbisheng commented May 15, 2024

What is changed and how it works?

Issue Number: Close #15972

What's Changed:

This commit implements a snapshot precheck process that leverages the snapshot
concurrency limiter introduced in #17015. The leader only proceeds to generate
the snapshot after it receives a precheck succeed message from the follower. The
precheck request and response are sent via the raft `ExtraMessage` where two new
message types are added in kvproto.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Release note

None

Copy link
Contributor

ti-chi-bot bot commented May 15, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Connor1996

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.

Copy link
Contributor

ti-chi-bot bot commented May 15, 2024

Hi @hbisheng. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

This commit implements a snapshot precheck process that leverages the snapshot
concurrency limiter introduced in tikv#17015. The leader only proceeds to generate
the snapshot after it receives a precheck succeed message from the follower. The
precheck request and response are sent via the raft `ExtraMessage` where two new
message types are added in kvproto.

TODO:
1. Handle the case where the follower is on an old version without the snapshot
precheck API.
2. Throttle the snapshot precheck requests, if necessary.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@hbisheng hbisheng marked this pull request as ready for review May 21, 2024 07:59
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@hbisheng
Copy link
Contributor Author

hbisheng commented May 22, 2024

I just realized a problem with the current concurrency limiter. If a single region leader keeps sending precheck requests to the same receiver (this may happen if the precheck response is somehow lost on the network), it would consume all reservations, thereby blocking other snapshots. I believe the concurrency limiter needs to be updated to deduplicate requests based on region_id.

Created #17051 for this.

@hbisheng hbisheng marked this pull request as draft May 22, 2024 05:37
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@hbisheng hbisheng marked this pull request as ready for review May 23, 2024 04:08
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@hbisheng hbisheng requested a review from Connor1996 May 23, 2024 05:59
components/raftstore/src/store/peer.rs Outdated Show resolved Hide resolved
components/raftstore/src/store/fsm/peer.rs Outdated Show resolved Hide resolved
…ant for precheck interval

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@hbisheng
Copy link
Contributor Author

/cc @overvenus for review

@ti-chi-bot ti-chi-bot bot requested a review from overvenus May 23, 2024 11:13
Copy link
Contributor

ti-chi-bot bot commented May 23, 2024

@hbisheng: GitHub didn't allow me to request PR reviews from the following users: for, review.

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

In response to this:

/cc @overvenus for review

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.

Copy link
Member

@overvenus overvenus 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

// Wait for the first snapshot to be received and paused.
let (tx, rx) = mpsc::channel();
let tx = Mutex::new(tx);
fail::cfg_callback("receiving_snapshot_callback", move || {
Copy link
Member

Choose a reason for hiding this comment

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

We can reuse receiving_snapshot_net_error as they are in the same position.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually using both failpoints. What I want to achieve is to trigger a callback AND pause the thread. I don't know if there's a way to do that with a single failpoint.

fail_point!("receiving_snapshot_callback");
fail_point!("receiving_snapshot_net_error");

components/test_raftstore/src/server.rs Show resolved Hide resolved
components/raftstore/src/store/peer_storage.rs Outdated Show resolved Hide resolved
components/raftstore/src/store/peer_storage.rs Outdated Show resolved Hide resolved
components/raftstore/src/store/fsm/peer.rs Outdated Show resolved Hide resolved
components/raftstore/src/store/fsm/peer.rs Outdated Show resolved Hide resolved
components/raftstore/src/store/fsm/peer.rs Show resolved Hide resolved
hbisheng and others added 2 commits May 31, 2024 15:53
Co-authored-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/XL and removed size/L labels May 31, 2024
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
…ck requests

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@hbisheng
Copy link
Contributor Author

hbisheng commented Jun 3, 2024

The PR is ready for another review @overvenus @Connor1996

… limiter

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@wuhuizuo
Copy link
Contributor

wuhuizuo commented Jun 4, 2024

/check-dco

Copy link
Contributor

ti-chi-bot bot commented Jun 4, 2024

Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits.

📝 Please follow instructions in the contributing guide to update your commits with the DCO

Full details of the Developer Certificate of Origin can be found at developercertificate.org.

The list of commits missing DCO signoff:

  • baaf635 Merge branch 'master' into snap-send-precheck-pr

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. I understand the commands that are listed here.

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
@Connor1996
Copy link
Member

/ok-to-test

Copy link
Contributor

ti-chi-bot bot commented Jun 6, 2024

@hbisheng: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-unit-test 211f5ee link true /test pull-unit-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

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 added the status/LGT1 Status: PR - There is already 1 approval label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TiKV should delay request snapshot if it exceeds receiving snapshot limit
4 participants