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

restore: precheck cluster is empty when first time full restore #45014

Merged
merged 15 commits into from
Jul 28, 2023

Conversation

3pointer
Copy link
Contributor

@3pointer 3pointer commented Jun 28, 2023

What problem does this PR solve?

Issue Number: close #35744

Problem Summary:

What is changed and how it works?

  1. Add pre-check for the first time FullRestore.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

Add a cluster empty precheck for full restore command

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 28, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 28, 2023
@3pointer
Copy link
Contributor Author

/run-integration-br-tests

@tiprow
Copy link

tiprow bot commented Jun 28, 2023

Hi @3pointer. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

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.

@3pointer
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Jun 28, 2023
@3pointer
Copy link
Contributor Author

/run-integration-br-tests

@3pointer
Copy link
Contributor Author

/run-integration-br-tests

1 similar comment
@3pointer
Copy link
Contributor Author

/run-integration-br-tests

@3pointer
Copy link
Contributor Author

/run-integration-br-tests

@3pointer
Copy link
Contributor Author

/ok-to-test

@3pointer
Copy link
Contributor Author

/run-integration-br-tests

@3pointer
Copy link
Contributor Author

/ok-to-test

@3pointer
Copy link
Contributor Author

/run-integration-br-tests

@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 label Jun 30, 2023
@3pointer
Copy link
Contributor Author

/ok-to-test

@3pointer
Copy link
Contributor Author

/run-integration-br-tests

@ti-chi-bot ti-chi-bot bot deleted a comment from ti-chi-bot Jun 30, 2023
@3pointer
Copy link
Contributor Author

/run-integration-br-tests

@ti-chi-bot ti-chi-bot bot added approved release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jul 5, 2023
@3pointer 3pointer added release-note-none Denotes a PR that doesn't merit a release note. and removed needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. labels Jul 6, 2023
@ti-chi-bot ti-chi-bot bot removed the release-note-none Denotes a PR that doesn't merit a release note. label Jul 6, 2023
Copy link
Contributor

@YuJuncen YuJuncen left a comment

Choose a reason for hiding this comment

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

Generally LGTM.

if isFullRestore(cmdName) {
// we need check cluster is fresh every time. except restore from a checkpoint.
if client.IsFull() && len(checkpointSetWithTableID) == 0 {
if err = client.CheckTargetClusterFresh(ctx); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will make BR fail once there are any table in the cluster. (Even there isn't intersection of them and the backup archive.) Will this break some use cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, It's intended @benmaoer has confirmed it. so this behaviour will introduced in v7.3. and won't cherry-pick back to any release versions.

Choose a reason for hiding this comment

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

Yes, there are 2 options:

  1. When restoring the entire cluster from a full backup, it is necessary to check whether the target cluster is an empty cluster, which has no user tables.

  2. When restoring specific tables or databases from the backup, it is necessary to detect if there are any conflicts between the tables to be restored and the existing tables in the target cluster. If conflicts are found, an error should be reported in advance to avoid data integrity issues.

Copy link

@dbakit dbakit Feb 4, 2024

Choose a reason for hiding this comment

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

Sometimes br restore full don't mean I realy want to resotre the entire cluster. In certain scenarios, I just want to restore multiple tables, but they are distributed across different databases. But neither br restore table nor br restore db supports regular expressions.
So, can you add a --force option to skip this check??

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 think maybe we should skip the check if user has specified --filter argument already. @benmaoer @YuJuncen WDYT?

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

ti-chi-bot bot commented Jul 25, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leavrth, YuJuncen

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:

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
Copy link

ti-chi-bot bot commented Jul 25, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-07-05 08:37:10.17892756 +0000 UTC m=+193062.112560980: ☑️ agreed by Leavrth.
  • 2023-07-25 05:52:17.573055215 +0000 UTC m=+247280.167586202: ☑️ agreed by YuJuncen.

@3pointer
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. labels Jul 28, 2023
@3pointer 3pointer removed needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. labels Jul 28, 2023
@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #45014 (1bd7abe) into master (79f0001) will increase coverage by 0.0167%.
Report is 3 commits behind head on master.
The diff coverage is 0.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #45014        +/-   ##
================================================
+ Coverage   73.2051%   73.2219%   +0.0167%     
================================================
  Files          1270       1276         +6     
  Lines        390023     390745       +722     
================================================
+ Hits         285517     286111       +594     
- Misses        86192      86287        +95     
- Partials      18314      18347        +33     
Flag Coverage Δ
integration 78.1388% <ø> (?)
unit 73.2133% <0.0000%> (+0.0082%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0417% <ø> (ø)
br 52.1520% <0.0000%> (+0.0113%) ⬆️

@ti-chi-bot ti-chi-bot bot merged commit 8c5ca7b into pingcap:master Jul 28, 2023
9 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BR restore failed: error="cannot find rewrite rule: [BR:Restore:ErrRestoreInvalidRewrite]invalid rewrite rule"
6 participants