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

DM/Openapi: support start task by some conditions #5349

Merged
merged 22 commits into from
May 16, 2022
Merged

DM/Openapi: support start task by some conditions #5349

merged 22 commits into from
May 16, 2022

Conversation

WizardXiao
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #5348

What is changed and how it works?

add start_time and safe_mode_time_duration in open api.

Check List

Tests

  • Unit test
  • Integration test

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented May 6, 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 release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 6, 2022
@WizardXiao WizardXiao added area/dm Issues or PRs related to DM. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 6, 2022
@ti-chi-bot ti-chi-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 6, 2022
@WizardXiao
Copy link
Contributor Author

/run-all-tests

@WizardXiao WizardXiao added the status/ptal Could you please take a look? label May 6, 2022
@WizardXiao
Copy link
Contributor Author

/cc @Ehco1996 @lance6716

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.

rest LGTM

dm/dm/config/task_converters.go Show resolved Hide resolved
safe_mode_time_duration:
type: string
example: "10s"
description: time duration of safe mode
Copy link
Contributor

Choose a reason for hiding this comment

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

we also support WaitTimeOnStop in cliArgs now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WaitTimeOnStop is not in the requirement, maybe i will add later pr and add some integration test.

@@ -2185,7 +2185,7 @@ func (s *Syncer) initSafeModeExitTS(firstBinlogTS int64) error {
return err
}
s.firstMeetBinlogTS = &firstBinlogTS
exitTS := firstBinlogTS + int64(duration.Seconds())
exitTS := firstBinlogTS + int64(duration.Seconds())*1000
Copy link
Contributor

Choose a reason for hiding this comment

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

why need *1000?

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, firstBinlogTS which comes from Timestamp is the value of millisecond,but duration is second. i find it when i run integration test.

Copy link
Contributor

Choose a reason for hiding this comment

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

you can use duration.Milliseconds() then

Copy link
Contributor

Choose a reason for hiding this comment

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

https://dev.mysql.com/doc/internals/en/binlog-event-header.html this should be the unit of second, not millisecond 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I have tried again, the value is uint32, i will fix back. I may modify this because I encounter another problem,the ts may be 0 when the event type is ROTATE_EVENT and then i modify here and avoid 0, but here is wrong.

@@ -684,3 +681,18 @@ func genFilterRuleName(sourceName string, idx int) string {
// NOTE that we don't have user input filter rule name in sub task config, so we make one by ourself
return fmt.Sprintf("%s-filter-rule-%d", sourceName, idx)
}

func OpenAPIStartTaskReqToTaskCliArgs(req openapi.StartTaskRequest) (*TaskCliArgs, error) {
cliArgs := &TaskCliArgs{}
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 return nil when all cli agrs are empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me have a try.

@WizardXiao
Copy link
Contributor Author

/run-all-tests

@WizardXiao
Copy link
Contributor Author

/run-all-tests

@WizardXiao
Copy link
Contributor Author

/run-all-tests

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/dm/config/task_converters.go Outdated Show resolved Hide resolved
dm/syncer/syncer.go Outdated Show resolved Hide resolved
openapi_task_check "get_task_list" 0

# incremental task use gtid
prepare_database
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test has source meta can exec

openapi_task_check "delete_task_with_force_success" "$task_name"
openapi_task_check "get_task_list" 0

# incremental task use start_time
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test has no source meta but has start time can exec

openapi_task_check "get_task_list" 0

# incremental task both gtid and start_time, start_time first
prepare_database
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test both has meta and start time, start time first.

openapi_task_check "get_task_list" 0

# incremental task no duration has error
export GO_FAILPOINTS='github.com/pingcap/tiflow/dm/syncer/SafeModeInitPhaseSeconds=return(0)'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test has no safe mode duration and has error

"query-status $task_name" \
"Duplicate entry" 2

# set duration and start again
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test set duration and can exec

@codecov-commenter
Copy link

codecov-commenter commented May 16, 2022

Codecov Report

Merging #5349 (fd8c8f9) into master (687e248) will decrease coverage by 0.4348%.
The diff coverage is 51.7090%.

Flag Coverage Δ
cdc 60.5260% <51.7090%> (-0.0726%) ⬇️
dm 51.9519% <ø> (-0.5177%) ⬇️

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

@@               Coverage Diff                @@
##             master      #5349        +/-   ##
================================================
- Coverage   56.1240%   55.6891%   -0.4349%     
================================================
  Files           522        528         +6     
  Lines         65325      69430      +4105     
================================================
+ Hits          36663      38665      +2002     
- Misses        25094      27042      +1948     
- Partials       3568       3723       +155     

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.

rest LGTM nice work

dm/dm/master/openapi_controller.go Outdated Show resolved Hide resolved
dm/tests/openapi/run.sh Show resolved Hide resolved
openapi_task_check "delete_task_with_force_success" "$task_name"
openapi_task_check "get_task_list" 0

# incremental task use start_time, but time is after create table
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test has start time but time is too late and return error.

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.

rest lgtm

@@ -705,10 +731,34 @@ func (s *Server) stopTask(ctx context.Context, taskName string, req openapi.Stop
sourceNameList := openapi.SourceNameList(s.getTaskSourceNameList(taskName))
req.SourceNameList = &sourceNameList
}
// TODO(ehco): support stop req after https://github.com/pingcap/tiflow/pull/4601 merged
// handle task cli args
cliArgs, err := config.OpenAPIStopTasReqToTaskCliArgs(req)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cliArgs, err := config.OpenAPIStopTasReqToTaskCliArgs(req)
cliArgs, err := config.OpenAPIStopTaskReqToTaskCliArgs(req)

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 plz fix typo before your merge

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

/run-all-tests

@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 May 16, 2022
@WizardXiao
Copy link
Contributor Author

/run-dm-integration-test

1 similar comment
@WizardXiao
Copy link
Contributor Author

/run-dm-integration-test

@WizardXiao
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: dd14d08

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

/run-dm-integration-test

2 similar comments
@WizardXiao
Copy link
Contributor Author

/run-dm-integration-test

@WizardXiao
Copy link
Contributor Author

/run-dm-integration-test

@ti-chi-bot ti-chi-bot merged commit da4924f into pingcap:master May 16, 2022
@WizardXiao WizardXiao mentioned this pull request May 17, 2022
5 tasks
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/XXL Denotes a PR that changes 1000+ 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. status/ptal Could you please take a look?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DM/Openapi: support start task by some conditions
6 participants