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

Extract common parts of ApplySnapshot #8110

Merged
merged 16 commits into from
Sep 19, 2023

Conversation

CalvinNeo
Copy link
Member

@CalvinNeo CalvinNeo commented Sep 18, 2023

What problem does this PR solve?

Issue Number: ref #8081

Problem Summary:

This is the second part of single big region snapshot handling. It mainly did the following:

  1. extract AsyncTasks as a common util
  2. gather SSTFilesToBlockInputStream's arguments into SSTFilesToBlockInputStreamOpts
  3. extract the three stream into readFromStream
  4. make readFromStream return error code rather than exception for recoverable error

What is changed and how it works?

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

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Signed-off-by: CalvinNeo <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 18, 2023
Signed-off-by: CalvinNeo <[email protected]>
f
Signed-off-by: CalvinNeo <[email protected]>
@@ -0,0 +1,95 @@
// Copyright 2023 PingCAP, Inc.
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved out from SSTFilesToBlockInputStream, with some header files excluded.

Signed-off-by: CalvinNeo <[email protected]>

#include <future>

namespace DB
{
template <typename Key, typename Func, typename R>
Copy link
Member Author

Choose a reason for hiding this comment

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

Intentionally, a packaged_task can be created from Func, which returns an R that is convertible from result_of(Func).

}
catch (DB::Exception & e)
{
if (e.code() == ErrorCodes::TABLE_IS_DROPPED)
Copy link
Member Author

Choose a reason for hiding this comment

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

The TABLE_IS_DROPPED exception here can still be thrown by some AtomicGetStorageSchema.

}
catch (DB::Exception & e)
{
if (stream != nullptr)
Copy link
Member Author

Choose a reason for hiding this comment

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

stream is released in readFromStream when abort.

.dt_disk_bytes = stream->getTotalBytesOnDisk(),
.dt_total_bytes = stream->getTotalCommittedBytes()}});
}
catch (DB::Exception & e)
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 release sst_stream here

@CalvinNeo
Copy link
Member Author

/run-all-tests

Signed-off-by: CalvinNeo <[email protected]>
f
Signed-off-by: CalvinNeo <[email protected]>
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

The rest LGTM

dbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Sep 19, 2023
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 19, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hongyunyan, JaySon-Huang

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 [JaySon-Huang,hongyunyan]

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 19, 2023
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 19, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-09-19 03:41:42.814780882 +0000 UTC m=+575268.782368917: ☑️ agreed by JaySon-Huang.
  • 2023-09-19 04:07:58.681925011 +0000 UTC m=+576844.649513046: ☑️ agreed by hongyunyan.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 19, 2023

@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

trigger some heavy tests which will not run always when PR updated.

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.

@CalvinNeo
Copy link
Member Author

/run-all-tests

@ti-chi-bot ti-chi-bot bot merged commit 158296d into pingcap:master Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants