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: Implement engine trait can_apply_snapshot #12924

Merged
merged 46 commits into from
Sep 8, 2022

Conversation

CalvinNeo
Copy link
Member

What is changed and how it works?

Issue Number: ref #12849

What's Changed:

Support new engine trait can_apply_snapshot

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
    • Consumes more MEM
  • Breaking backward compatibility

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jun 28, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • BusyJay
  • tonyxuqqi

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 added release-note-none Denotes a PR that doesn't merit a release note. contribution This PR is from a community contributor. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 28, 2022
components/engine_rocks/src/engine.rs Outdated Show resolved Hide resolved
components/engine_rocks/src/engine.rs Outdated Show resolved Hide resolved
components/engine_traits/src/engine.rs Outdated Show resolved Hide resolved
components/engine_rocks/src/raw_util.rs Outdated Show resolved Hide resolved
Signed-off-by: CalvinNeo <[email protected]>
Signed-off-by: CalvinNeo <[email protected]>
@CalvinNeo CalvinNeo requested a review from tonyxuqqi June 29, 2022 07:16
@CalvinNeo
Copy link
Member Author

/run-all-tests

2 similar comments
@CalvinNeo
Copy link
Member Author

/run-all-tests

@CalvinNeo
Copy link
Member Author

/run-all-tests

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 16, 2022
m
Signed-off-by: CalvinNeo <[email protected]>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 18, 2022
f
Signed-off-by: CalvinNeo <[email protected]>
@CalvinNeo
Copy link
Member Author

/run-all-tests

@CalvinNeo
Copy link
Member Author

/cc @BusyJay

@ti-chi-bot ti-chi-bot requested a review from BusyJay August 22, 2022 05:38
@@ -66,6 +66,10 @@ impl RocksEngine {
self.shared_block_cache = enable;
}

pub fn get_shared_block_cache(&self) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

Should be shared_block_cache. Note we will remove the field in the future and cache will be always shared.

/// Some KvEngines need to do some transforms before apply data from
/// snapshot. These procedures can be batched in background if there are
/// more than one incoming snapshots, thus not blocking applying thread.
fn can_apply_snapshot(&self, _is_timeout: bool, _region_id: u64) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

Why need is_timeout? How can it make any difference?

Copy link
Member Author

Choose a reason for hiding this comment

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

If there is no incoming applying snapshot for a long time, handle_pending_applies can be triggered by on_timeout, thus proxy can do it directly in foreground.

Copy link
Member

@BusyJay BusyJay Aug 22, 2022

Choose a reason for hiding this comment

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

Then why bother calling can_apply_snapshot again when timeout?

Copy link
Member Author

@CalvinNeo CalvinNeo Aug 24, 2022

Choose a reason for hiding this comment

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

handle_pending_applies will apply multiple snapshots as long as it will not cause write stall. However, in proxy we won't handle the more than one snapshot if the following snapshot is still pre-handling, thus avoid continuous blocking of the thread for applying snapshot.

f
Signed-off-by: CalvinNeo <[email protected]>
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 24, 2022
@ti-chi-bot ti-chi-bot removed the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 24, 2022
@CalvinNeo CalvinNeo force-pushed the merge-tikv-engine-trait branch 3 times, most recently from 11d38f6 to 31ee9ca Compare September 6, 2022 12:24
@CalvinNeo CalvinNeo force-pushed the merge-tikv-engine-trait branch from 31ee9ca to 3d73188 Compare September 6, 2022 14:20
@CalvinNeo
Copy link
Member Author

/run-all-tests

@CalvinNeo
Copy link
Member Author

/cc @breezewish

@breezewish
Copy link
Member

The rest looks good to me. @tonyxuqqi PTAL, thanks!

@CalvinNeo CalvinNeo requested a review from tonyxuqqi September 8, 2022 02:27
const PENDING_APPLY_CHECK_INTERVAL: u64 = 200;
const STALE_PEER_CHECK_TICK: usize = 1;

fn make_raftstore_cfg(use_delete_range: bool) -> Arc<VersionTrack<Config>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

all these configuration except use_delete_range parameter are hardcoded. So what's the point of creating a config instead of hardcode in the RegionRunner ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also please add a comment to clarify what's the consumer of this Config. It may be easily confused as the config used by raftstore itself.

@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 Sep 8, 2022
CalvinNeo and others added 7 commits September 8, 2022 12:57
f
Signed-off-by: CalvinNeo <[email protected]>
f
Signed-off-by: CalvinNeo <[email protected]>
f
Signed-off-by: CalvinNeo <[email protected]>
f
Signed-off-by: CalvinNeo <[email protected]>
f
Signed-off-by: CalvinNeo <[email protected]>
@breezewish
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

@breezewish: 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.

@ti-chi-bot
Copy link
Member

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

Commit hash: 14b003a

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 8, 2022
@ti-chi-bot ti-chi-bot merged commit 079a069 into tikv:master Sep 8, 2022
@ti-chi-bot ti-chi-bot added this to the Pool milestone Sep 8, 2022
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Sep 9, 2022
ref tikv#12849

Support new engine trait can_apply_snapshot

Signed-off-by: CalvinNeo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. 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.

6 participants