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 1 commit 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
  • overvenus

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.

@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
@hbisheng hbisheng marked this pull request as ready for review May 23, 2024 04:08
@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
@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
@ti-chi-bot ti-chi-bot bot removed the size/L label May 31, 2024
@ti-chi-bot ti-chi-bot bot added the size/XL label May 31, 2024
@hbisheng
Copy link
Contributor Author

hbisheng commented Jun 3, 2024

The PR is ready for another review @overvenus @Connor1996

@wuhuizuo
Copy link
Contributor

wuhuizuo commented Jun 4, 2024

/check-dco

@Connor1996
Copy link
Member

/ok-to-test

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
@ti-chi-bot ti-chi-bot bot added status/LGT2 Status: PR - There are already 2 approvals approved and removed status/LGT1 Status: PR - There is already 1 approval labels Jun 6, 2024
@hbisheng
Copy link
Contributor Author

/check-dco

@hbisheng
Copy link
Contributor Author

/retest

@Connor1996
Copy link
Member

/merge

Copy link
Contributor

ti-chi-bot bot commented Jun 11, 2024

@Connor1996: We have migrated to builtin LGTM and approve plugins for reviewing.

👉 Please use /approve when you want approve this pull request.

The changes announcement: Proposal: Strengthen configuration change approval.

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.

@Connor1996
Copy link
Member

/approve

Copy link
Contributor

ti-chi-bot bot commented Jun 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Connor1996, overvenus

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Connor1996,overvenus]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

(commits squashed)

Signed-off-by: Bisheng Huang <hbisheng@gmail.com>
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