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

syncer(dm): implement start-task --start-time #4485

Merged
merged 12 commits into from
Feb 14, 2022

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Jan 26, 2022

What problem does this PR solve?

Issue Number: close #4106

What is changed and how it works?

continue on previous PRs, now syncer of DM worker should first find the corresponding binlog location of --start-time, clean outdated checkpoints and save it to global checkpoint. After the first time global checkpoint is flushed, DM worker also tries to clean the task command line arguments saved in etcd.

Check List

Tests

  • Integration test

Code changes

  • Has interface methods change

Side effects

Related changes

Release note

Support start-task with `--start-time`.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 26, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • D3Hunter
  • Ehco1996

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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. labels Jan 26, 2022
@lance6716 lance6716 added the area/dm Issues or PRs related to DM. label Jan 26, 2022
@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 Jan 26, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2022

Codecov Report

Merging #4485 (715b434) into master (9607554) will decrease coverage by 0.1286%.
The diff coverage is 59.6401%.

Flag Coverage Δ
cdc 60.3071% <59.3750%> (+0.3849%) ⬆️
dm 51.4451% <59.7194%> (-0.5838%) ⬇️

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

@@               Coverage Diff                @@
##             master      #4485        +/-   ##
================================================
- Coverage   55.6402%   55.5116%   -0.1287%     
================================================
  Files           494        506        +12     
  Lines         61283      62722      +1439     
================================================
+ Hits          34098      34818       +720     
- Misses        23750      24430       +680     
- Partials       3435       3474        +39     

@lance6716 lance6716 changed the title [WIP] syncer(dm): implement start-task --start-time syncer(dm): implement start-task --start-time Jan 27, 2022
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed 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 Jan 27, 2022
@lance6716
Copy link
Contributor Author

/cc @D3Hunter

@lance6716
Copy link
Contributor Author

/run-dm-integration-test

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 7, 2022
@ti-chi-bot ti-chi-bot added do-not-merge/needs-triage-completed and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 8, 2022
if err != nil {
return err
if s.cfg.Meta == nil || s.cfg.Meta.BinLogName != binlog.FakeBinlogName {
err = s.setInitActiveRelayLog(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

seems setInitActiveRelayLog can move to sync.Run so that we don't need this check s.cfg.Meta.BinLogName != binlog.FakeBinlogName ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when Init syncer, set active relay log info

we will risk the relay log being purged between Init and Run. I prefer we don't change old logic if we don't have enough thinking.

Copy link
Contributor

Choose a reason for hiding this comment

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

but if we into this branch s.cfg.Meta.BinLogName != binlog.FakeBinlogName user still have this risk

so how about make setInitActiveRelayLog support set binlog user want to start in s.Init ? i mean call binlog finder in init

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Init should not have long-running tasks by definition, it will cause whole pipeline timeout.

dm/syncer/syncer.go Show resolved Hide resolved
dm/syncer/syncer.go Show resolved Hide resolved
dm/syncer/syncer.go Outdated Show resolved Hide resolved
dm/syncer/syncer.go Show resolved Hide resolved
}
err = cfg.Adjust()
} else {
err = cfg.Decode(task)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we set inst.Meta after cfg.Decode? So we no need RawDecode and Adjust, only depend on cfg.Decode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cfg.Decode will call adjust internally, then it will report error about inst.Meta.


cp.logCtx.L().Info("delete all table checkpoint")
_, err := cp.dbConn.ExecuteSQL(
tctx,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use maxDMLConnectionDuration or defaultDBTimeout?

zap.String("time", timeStr),
zap.Stringer("pos", loc))
case binlog.BelowLowerBoundBinlogPos:
s.tctx.L().Warn("fail to find binlog location by timestamp because the timestamp is too early, will use the earliest binlog location",
Copy link
Contributor

Choose a reason for hiding this comment

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

Will return error better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"stop-task test" \
"\"result\": true" 2
Copy link
Contributor

Choose a reason for hiding this comment

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

How about triger a worker transfer event here?

if s.cliArgs != nil && s.cliArgs.StartTime != "" {
clone := *s.cliArgs
clone.StartTime = ""
err2 := ha.PutTaskCliArgs(s.cli, s.cfg.Name, []string{s.cfg.SourceID}, clone)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use DelTaskCliBySource?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we might have more args in near future, so for compatible I should only remove the least argument.

Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

will review test later.

dm/pkg/binlog/pos_finder.go Outdated Show resolved Hide resolved
dm/syncer/checkpoint.go Outdated Show resolved Hide resolved
dm/syncer/syncer.go Show resolved Hide resolved
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.

will review test later

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

dm/syncer/checkpoint.go Outdated Show resolved Hide resolved
dm/tests/start_task/run.sh Show resolved Hide resolved
dm/tests/start_task/run.sh Show resolved Hide resolved
dm/tests/start_task/run.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 14, 2022
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.

LGTM

@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 14, 2022
@lance6716
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 71a9cda

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 14, 2022
@lance6716
Copy link
Contributor Author

/run-verify

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Feb 14, 2022
@lance6716
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 3ba5edd

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 14, 2022
@lance6716
Copy link
Contributor Author

/merge

@lance6716
Copy link
Contributor Author

/run-verify

@lance6716
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@lance6716: 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 803aa92 into pingcap:master Feb 14, 2022
zhaoxinyu pushed a commit to zhaoxinyu/ticdc that referenced this pull request Feb 16, 2022
@lance6716 lance6716 deleted the start-time-2 branch October 13, 2022 08:38
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 Denotes a PR that will be considered when it comes time to generate release notes. 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.

dmctl can specify start-time to start an incremental migration task
6 participants