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: allow exec observers delay deletion of applied ssts #13061

Merged
merged 34 commits into from Aug 16, 2022

Conversation

CalvinNeo
Copy link
Member

@CalvinNeo CalvinNeo commented Jul 20, 2022

What is changed and how it works?

Issue Number: ref #12849

What's Changed:

Some KvEngine can't actually ingest sst, since they do not use RocksDB as a backend. So they may decode the sst, and store them in memory. If we delete the sst file immediately, we may lost data if we have not persist our data in KvEngine.

However, we can't do a persistence for every ingest sst request, this just cost too much. So we introduce this PR to allow a delay deletion of sst files, controlled by post_exec.

allow exec observers delay deletion of applied ssts

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>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@ti-chi-bot
Copy link
Member

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

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

/cc @BusyJay @tonyxuqqi

CalvinNeo and others added 3 commits July 20, 2022 13:11
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-build-arm64 comment=true

@CalvinNeo CalvinNeo changed the title raftstore: allow exec observers delay deletion of applied ssts. raftstore: allow exec observers delay deletion of applied ssts Jul 22, 2022
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 CalvinNeo requested a review from BusyJay August 1, 2022 05:20
c
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
_: &RegionState,
_: &mut ApplyCtxInfo<'_>,
) -> bool {
self.called.fetch_add(18, Ordering::SeqCst);
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the meaning of 18 and all other numbers below

Copy link
Member Author

Choose a reason for hiding this comment

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

In this test, we assign unique index for each observer functions so that we can test all of the observer functions we want to be called are called. All numbers below 18 are used for other functions, so we use 18 for post_exec.

pub struct ApplyCtxInfo<'a> {
pub pending_handle_ssts: &'a mut Option<Vec<SstMetaInfo>>,
pub delete_ssts: &'a mut Vec<SstMetaInfo>,
pub pending_delete_ssts: &'a mut Vec<SstMetaInfo>,
Copy link
Contributor

Choose a reason for hiding this comment

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

where's the code that consumes pending_delete_ssts and delete the SST files?
How can we ensure that these SST files are finally deleted?

Copy link
Member Author

Choose a reason for hiding this comment

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

In TiKV's view:
post_exec will consumes pending_delete_ssts, and it will return true to suggest a immediate write to db.
In TiFlash's view:
When all data referred in the ssts is write into TiFlash's storage, TiFlash will consume pending_delete_ssts and suggest a write.
If TiFlash&Proxy restart before persistence, the recovered applied_index is before IngestSst command. So we can replay this command, and thus ensuring we will not lost track of sst files.

Copy link
Contributor

Choose a reason for hiding this comment

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

In TiKV's view: post_exec will consumes pending_delete_ssts, and it will return true to suggest a immediate write to db. In TiFlash's view: When all data referred in the ssts is write into TiFlash's storage, TiFlash will consume pending_delete_ssts and suggest a write. If TiFlash&Proxy restart before persistence, the recovered applied_index is before IngestSst command. So we can replay this command, and thus ensuring we will not lost track of sst files.

IC. Then is there any metrics for pending_delete_ssts? We need to have a way to figure this out.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have a tikv_raft_applying_sst added
image

CalvinNeo and others added 4 commits August 16, 2022 01:42
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/XL and removed size/L labels Aug 16, 2022
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@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 Aug 16, 2022
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>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@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: 08ec612

@ti-chi-bot ti-chi-bot added the status/can-merge Status: Can merge to base branch label Aug 16, 2022
@ti-chi-bot
Copy link
Member

@CalvinNeo: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

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 merged commit dabf29e into tikv:master Aug 16, 2022
@ti-chi-bot ti-chi-bot added this to the Pool milestone Aug 16, 2022
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Aug 16, 2022
…13061)

ref tikv#12849

allow exec observers delay deletion of applied ssts

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

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
fengou1 pushed a commit to fengou1/tikv that referenced this pull request Aug 30, 2022
…13061)

ref tikv#12849

allow exec observers delay deletion of applied ssts

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

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Signed-off-by: fengou1 <feng.ou@pingcap.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/XL 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

6 participants