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

loader(dm): simplify lightning checkpoint and add clean meta #3813

Merged
merged 18 commits into from
Dec 22, 2021

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Dec 9, 2021

What problem does this PR solve?

Close #3509

What is changed and how it works?

  • Simplify lightning checkpoint logic by:
    • change lightning checkpoint type from mysql to file and stop the file checkpoint at dump dir
    • Change lightning_checkpoint_list table in downstream for (task-name, worker-name) to (task-name, source-name, status). Lightning depend this table to check its load status (fresh, loading, finished).

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Code changes

  • Has persistent data change

Side effects

  • Breaking backward compatibility
    • This new implement is not compatible with the previous implement because lightning checkpoint data is changed.

Related changes

Release note

None

@glorv glorv added the area/dm Issues or PRs related to DM. label Dec 9, 2021
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 9, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Ehco1996
  • lichunzhu

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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 9, 2021
@glorv
Copy link
Contributor Author

glorv commented Dec 9, 2021

/run-dm-integration-test

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Dec 9, 2021
@glorv
Copy link
Contributor Author

glorv commented Dec 9, 2021

/run-dm-integration-test

@glorv
Copy link
Contributor Author

glorv commented Dec 10, 2021

/run-dm-integration-test

@glorv
Copy link
Contributor Author

glorv commented Dec 10, 2021

/run-dm-integration-test

@glorv glorv marked this pull request as ready for review December 10, 2021 06:24
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 10, 2021
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 10, 2021
@glorv
Copy link
Contributor Author

glorv commented Dec 10, 2021

/run-dm-integration-test

@glorv
Copy link
Contributor Author

glorv commented Dec 10, 2021

/run-verify

dm/loader/checkpoint.go Outdated Show resolved Hide resolved
dm/loader/lightning.go Show resolved Hide resolved
dm/loader/checkpoint.go Show resolved Hide resolved

const (
lightningStatusInit lightingLoadStatus = iota
lightningStatusRunning
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe reuse CheckpointStatus in tidb/pkg/checkpoints ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean the real tidb-lightning's CheckpointStatus ? I think because there are so many state in it, it maybe hard to understand of not familiar with tidb-lightning

Copy link
Contributor

Choose a reason for hiding this comment

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

oh my fault i got the two status mixed up, now i think the current implementaion make more sense

btw, how about direct use char like init,running , finished in db? maybe this can increase readability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


const (
lightningStatusInit lightingLoadStatus = iota
lightningStatusRunning
Copy link
Contributor

Choose a reason for hiding this comment

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

oh my fault i got the two status mixed up, now i think the current implementaion make more sense

btw, how about direct use char like init,running , finished in db? maybe this can increase readability

return lightningStatusInit, nil
}

func (cp *LightningCheckpointList) RemoveTaskCheckPoint(ctx context.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

when is this function to be called ?

Copy link
Contributor Author

@glorv glorv Dec 15, 2021

Choose a reason for hiding this comment

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

No used now. It is orginally designed for being calling at cleanup meta, but the current design just call raw drop table like other tables. 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

so we can delete this func?

Copy link
Contributor

@Ehco1996 Ehco1996 left a comment

Choose a reason for hiding this comment

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

restLGTM

return lightningStatusInit, nil
}

func (cp *LightningCheckpointList) RemoveTaskCheckPoint(ctx context.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

so we can delete this func?

Copy link
Contributor

@lichunzhu lichunzhu left a comment

Choose a reason for hiding this comment

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

Should lightning's pb checkpoint be removed when we remove-meta? Or maybe left a comment?
We don't have a task contains only load+sync, but I'm not sure whether we will have this kind of task in the future or not.

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

glorv commented Dec 17, 2021

Should lightning's pb checkpoint be removed when we remove-meta? Or maybe left a comment? We don't have a task contains only load+sync, but I'm not sure whether we will have this kind of task in the future or not.

The checkpoint is under dump directory, so it can be cleaned up when dump data is cleaned.

@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2021

Codecov Report

Merging #3813 (5c489fd) into master (3873d39) will decrease coverage by 1.7643%.
The diff coverage is 61.7801%.

Flag Coverage Δ
cdc 58.1969% <61.7801%> (-0.0396%) ⬇️
dm 52.8655% <ø> (-3.1690%) ⬇️

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

@@               Coverage Diff                @@
##             master      #3813        +/-   ##
================================================
- Coverage   57.0741%   55.3098%   -1.7644%     
================================================
  Files           478        484         +6     
  Lines         56551      59060      +2509     
================================================
+ Hits          32276      32666       +390     
- Misses        20978      23090      +2112     
- Partials       3297       3304         +7     

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 17, 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 Dec 20, 2021
@glorv
Copy link
Contributor Author

glorv commented Dec 21, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 5c489fd

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

@glorv: 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.

@Ehco1996
Copy link
Contributor

/run-kafka-integration-test /tidb=pr/30773
/run-integration-tests /tidb=pr/30773

@ti-chi-bot ti-chi-bot merged commit d84f15b into pingcap:master Dec 22, 2021
@glorv glorv deleted the lighting-cp branch December 28, 2021 11:44
zhaoxinyu pushed a commit to zhaoxinyu/ticdc that referenced this pull request Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dm Issues or PRs related to DM. 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. 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-loader support --remove-meta
5 participants