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: save status checkpoint synchronously #27096

Merged
merged 11 commits into from
Aug 31, 2021

Conversation

sleepymole
Copy link
Contributor

What problem does this PR solve?

Close pingcap/br#1372.
Same as pingcap/br#1304.

We save status checkpoint after import finished, and then clean up the engine.

err := closedEngine.Import(ctx)
rc.saveStatusCheckpoint(tr.tableName, engineID, err, checkpoints.CheckpointStatusImported)
// Also cleanup engine when encountered ErrDuplicateDetected, since all duplicates kv pairs are recorded.
if err == nil {
err = multierr.Append(err, closedEngine.Cleanup(ctx))
}

But saveStatusCheckpoint saves checkpoint asynchronously, an engine may be cleaned up successfully but exit before update checkpoint. After restart, verifyLocalFile will fail.
func verifyLocalFile(ctx context.Context, cpdb checkpoints.DB, dir string) error {

To solve this issue, we can save status synchronously. An engine can only be cleaned up after the checkpoint has been successfully saved. Since we don't change the status of the engine very often, I think synchronously saving status checkpoint is acceptable and it can also avoid some unusual situations.

Related unstable integration test: lightning_checkpoint_engines_order.

What is changed and how it works?

Save save status checkpoint synchronously.

Check List

Tests

  • Unit test
  • Integration test

Release note

lightning: save status checkpoint synchronously

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 11, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • glorv
  • 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 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. labels Aug 11, 2021
@sleepymole
Copy link
Contributor Author

/sig migrate
/cc @glorv @kennytm

@kennytm
Copy link
Contributor

kennytm commented Aug 12, 2021

/component lightning
/run-check_dev_2 #26947

@ti-chi-bot ti-chi-bot added the component/lightning This issue is related to Lightning of TiDB. label Aug 12, 2021
@glorv
Copy link
Contributor

glorv commented Aug 13, 2021

[2021-08-12T17:40:18.849Z] FAIL: restore_test.go:1001: tableRestoreSuite.TestSaveStatusCheckpoint

[2021-08-12T17:40:18.849Z] 

[2021-08-12T17:40:18.849Z] restore_test.go:1025:

[2021-08-12T17:40:18.849Z]     c.Assert(elapsed, GreaterEqual, time.Millisecond*100)

[2021-08-12T17:40:18.849Z] ... compare_one time.Duration = 77689 ("77.689µs")

[2021-08-12T17:40:18.849Z] ... compare_two time.Duration = 100000000 ("100ms")

@gozssky

@sleepymole
Copy link
Contributor Author

[2021-08-12T17:40:18.849Z] FAIL: restore_test.go:1001: tableRestoreSuite.TestSaveStatusCheckpoint

[2021-08-12T17:40:18.849Z] 

[2021-08-12T17:40:18.849Z] restore_test.go:1025:

[2021-08-12T17:40:18.849Z]     c.Assert(elapsed, GreaterEqual, time.Millisecond*100)

[2021-08-12T17:40:18.849Z] ... compare_one time.Duration = 77689 ("77.689µs")

[2021-08-12T17:40:18.849Z] ... compare_two time.Duration = 100000000 ("100ms")

@gozssky

@glorv Fixed.

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

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

rest LGTM

sleepymole and others added 4 commits August 26, 2021 10:29
Co-authored-by: kennytm <kennytm@gmail.com>
Co-authored-by: kennytm <kennytm@gmail.com>
Co-authored-by: kennytm <kennytm@gmail.com>
@glorv
Copy link
Contributor

glorv commented Aug 26, 2021

/run-check_dev_2

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 29, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 30, 2021
@sleepymole sleepymole requested a review from kennytm August 30, 2021 03:06
@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 Aug 30, 2021
@sleepymole
Copy link
Contributor Author

/run-integraion-tests

@kennytm
Copy link
Contributor

kennytm commented Aug 31, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: ff3ca70

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 31, 2021
@ti-chi-bot
Copy link
Member

@gozssky: 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 f8b4713 into pingcap:master Aug 31, 2021
joccau pushed a commit to joccau/tidb that referenced this pull request Sep 7, 2021
@sleepymole sleepymole deleted the checkpoint branch September 23, 2021 08:55
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/migrate 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.

Unstable lightning test lightning_checkpoint_engines_order
4 participants