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

lightning: skip restore table when source files are empty #28189

Merged
merged 9 commits into from
Feb 16, 2022

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Sep 18, 2021

What problem does this PR solve?

Issue Number: close #28144

Problem Summary:

What is changed and how it works?

Skip restore table when there are no source files.

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

Fix the bug that lightning may not clean up metadata schema when some of the import contains no source files.

@glorv glorv added needs-cherry-pick-release-5.2 component/lightning This issue is related to Lightning of TiDB. labels Sep 18, 2021
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 18, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • gozssky
  • kennytm

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. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 18, 2021
@sleepymole
Copy link
Contributor

There are at least four special judgments(include this PR) for empty source table 😂, can we unify them in one place?

@ti-chi-bot ti-chi-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 18, 2021
@kennytm kennytm changed the title br: skip restore table when source files are empty lightning: skip restore table when source files are empty Sep 18, 2021
@glorv
Copy link
Contributor Author

glorv commented Sep 18, 2021

/run-all-tests

@glorv
Copy link
Contributor Author

glorv commented Sep 18, 2021

/run-integration-br-tests

@@ -1349,6 +1349,9 @@ func (rc *Controller) restoreTables(ctx context.Context) error {
if err != nil {
return errors.Trace(err)
}
if cp.Status < checkpoints.CheckpointStatusAllWritten && len(tableMeta.DataFiles) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why cp.Status < checkpoints.CheckpointStatusAllWritten is needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If cp.Status >= CheckpointStatusAllWritten then the restore process has no relation with the source files anymore, so we may allow it to continue even if we find there are no source files. Maybe there are situations that the source files are corrupted, the import phase can still go on.😅

Copy link
Member

Choose a reason for hiding this comment

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

Comparing statue is wired. Status is not a clear name, Rename it to stage or something similar would be more clear.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 18, 2021
Copy link
Contributor

@Little-Wallace Little-Wallace left a comment

Choose a reason for hiding this comment

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

LGTM. But I think we shall not decide checksum and meta-table in one condition code.

@glorv
Copy link
Contributor Author

glorv commented Oct 19, 2021

LGTM. But I think we shall not decide checksum and meta-table in one condition code.

I thought about this, but it's not easy to do so. In theory the management of metadata should be decouple, but because only after checksum can we know whether the metadata can be cleaned up. Another option is to always do check and cleanup on demand after restore table, but this kind of approach can't take advantage of the information after checksum. Not sure if we need to move this cleanup logic after restore table, the logic will be more complex than the current implement.

@glorv
Copy link
Contributor Author

glorv commented Oct 19, 2021

/hold

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 19, 2021
@ti-chi-bot ti-chi-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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 15, 2022
@glorv
Copy link
Contributor Author

glorv commented Feb 15, 2022

/run-integration-br-test

@kennytm
Copy link
Contributor

kennytm commented Feb 15, 2022

the new test failed.

https://ci.pingcap.net/blue/organizations/jenkins/br_ghpr_unit_and_integration_test/detail/br_ghpr_unit_and_integration_test/10068/pipeline/102

[2022-02-15T07:45:40.787Z] *************************** 1. row ***************************

[2022-02-15T07:45:40.787Z] Database: lightning_metadata

[2022-02-15T07:45:40.787Z] TEST FAILED: OUTPUT CONTAINS 'Database: lightning_metadata'

[2022-02-15T07:45:40.787Z] ____________________________________

[2022-02-15T07:45:40.787Z] [Tue Feb 15 15:45:39 CST 2022] Executing SQL: SHOW DATABASES like 'lightning_metadata';

[2022-02-15T07:45:40.787Z] *************************** 1. row ***************************

[2022-02-15T07:45:40.787Z] Database: lightning_metadata

[2022-02-15T07:45:40.787Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 15, 2022
@glorv
Copy link
Contributor Author

glorv commented Feb 15, 2022

/run-integration-br-test

@glorv
Copy link
Contributor Author

glorv commented Feb 15, 2022

the new test failed.

https://ci.pingcap.net/blue/organizations/jenkins/br_ghpr_unit_and_integration_test/detail/br_ghpr_unit_and_integration_test/10068/pipeline/102

[2022-02-15T07:45:40.787Z] *************************** 1. row ***************************

[2022-02-15T07:45:40.787Z] Database: lightning_metadata

[2022-02-15T07:45:40.787Z] TEST FAILED: OUTPUT CONTAINS 'Database: lightning_metadata'

[2022-02-15T07:45:40.787Z] ____________________________________

[2022-02-15T07:45:40.787Z] [Tue Feb 15 15:45:39 CST 2022] Executing SQL: SHOW DATABASES like 'lightning_metadata';

[2022-02-15T07:45:40.787Z] *************************** 1. row ***************************

[2022-02-15T07:45:40.787Z] Database: lightning_metadata

[2022-02-15T07:45:40.787Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Fixed. Since we don't support incremental restore for importer backend, I just from the case for importer in lightning_incremental.

@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 Feb 15, 2022
@glorv
Copy link
Contributor Author

glorv commented Feb 16, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: d4e8eef

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 16, 2022
@ti-chi-bot ti-chi-bot merged commit 706f8a9 into pingcap:master Feb 16, 2022
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Feb 16, 2022
@ti-srebot
Copy link
Contributor

cherry pick to release-5.2 in PR #32388

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Feb 16, 2022
@ti-srebot
Copy link
Contributor

cherry pick to release-5.3 in PR #32389

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Feb 16, 2022
@ti-srebot
Copy link
Contributor

cherry pick to release-5.4 in PR #32390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/lightning This issue is related to Lightning of TiDB. needs-cherry-pick-release-5.2 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Lightning: lightning_metadata not deleted after import exit successfully
8 participants