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 coprocessor observer pre_persist #12957

Merged
merged 16 commits into from Sep 15, 2022

Conversation

CalvinNeo
Copy link
Member

@CalvinNeo CalvinNeo commented Jul 5, 2022

Signed-off-by: CalvinNeo calvinneo1995@gmail.com

What is changed and how it works?

Issue Number: ref #12849

What's Changed:

Before commit and finish_for, if the observer decides it is not a proper time to do actual persist, it can skip this persistence.
This observer is aim to disable persistence of advanced applied_index, since some KvEngine may not persist replicated data when commit and finish_for, so we can persist advanced applied_index either.
This can be easily done if we just disable write_apply_state. However, TiKV assert that data and meta should be persist as a whole, so if we don't want to persist advanced applied_index, we should not persist data(which is actually empty, except some pending deleting ssts) either.
We don't worry too much about rubbish data. Since commit can also be triggered by post_exec, or at least ApplyContext::end. We don't call write_apply_sate in ApplyContext::end.

Support coprocessor observer pre_commit

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

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

ti-chi-bot commented Jul 5, 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.

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/cc @tonyxuqqi @BusyJay

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
CalvinNeo and others added 2 commits September 6, 2022 12:47
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@ti-chi-bot ti-chi-bot added size/L and removed size/M labels Sep 9, 2022
/// For example, in `finish_for` and `commit`,
/// we will separately call `pre_commit` with is_finished = true/false.
/// By returning false, we reject this persistence.
pub fn pre_commit(
Copy link
Member

Choose a reason for hiding this comment

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

Better give it a better name without leaking the implementation details. It will be changed in v2.

@@ -269,6 +269,7 @@ impl Simulator for NodeCluster {
.max_total_size(cfg.server.snap_max_total_size.0)
.encryption_key_manager(key_manager)
.max_per_file_size(cfg.raft_store.max_snapshot_file_raw_size.0)
.enable_multi_snapshot_files(true)
Copy link
Member

Choose a reason for hiding this comment

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

Why the change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I find test cases like test_server_huge_snapshot_multi_files may not check expected behavior if enable_multi_snapshot_files is set to false.
These tests are to test if snapshot works fine when we enable multi file snapshot. However, we may not generate multi file snapshot if this switch is closed, so these tests will actually test single file snapshot.

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@ti-chi-bot ti-chi-bot added the status/LGT1 Status: PR - There is already 1 approval label Sep 14, 2022
@ti-chi-bot ti-chi-bot added status/LGT2 Status: PR - There are already 2 approvals and removed status/LGT1 Status: PR - There is already 1 approval labels Sep 15, 2022
@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: b57d9e8

@ti-chi-bot ti-chi-bot added the status/can-merge Status: Can merge to base branch label Sep 15, 2022
@CalvinNeo CalvinNeo changed the title raftstore: Implement coprocessor observer pre_commit raftstore: Implement coprocessor observer pre_persist Sep 15, 2022
@CalvinNeo
Copy link
Member Author

/run-all-tests

@ti-chi-bot ti-chi-bot merged commit 592d423 into tikv:master Sep 15, 2022
@ti-chi-bot ti-chi-bot added this to the Pool milestone Sep 15, 2022
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Sep 15, 2022
ref tikv#12849

Support coprocessor observer pre_commit

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Sep 15, 2022
ref tikv#12849

Support coprocessor observer pre_commit

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Sep 15, 2022
ref tikv#12849

Support coprocessor observer pre_commit

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Sep 15, 2022
ref tikv#12849

Support coprocessor observer pre_commit

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Sep 15, 2022
ref tikv#12849

Support coprocessor observer pre_commit

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution Type: PR - From contributors release-note-none size/L status/can-merge Status: Can merge to base branch status/LGT2 Status: PR - There are already 2 approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants