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

master(dm): support create a task in stopped state #4510

Merged
merged 47 commits into from
Mar 3, 2022
Merged

master(dm): support create a task in stopped state #4510

merged 47 commits into from
Mar 3, 2022

Conversation

Ehco1996
Copy link
Contributor

@Ehco1996 Ehco1996 commented Feb 7, 2022

What problem does this PR solve?

Issue Number: ref #4484

What is changed and how it works?

for master

  • separate openapi.go into openapi_view.go and openapi_controaller.go, more inner logic such as filter,validate, and organze reponse will be add to openapi_controaller
  • scheduler support create a task in stopped stage
  • add new task OP op_delete in proto, when worker see this op, it will delete this subtask
  • dmctl stop-task now use op_delete to update task stage

for worker

  • support start a task in stopped stage when subtask not started
  • update operateSubTaskStage logic to match new stage

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has interface methods change

Side effects

  • Increased code complexity

Related changes

Release note

support create a task in `stopped` state.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 7, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • D3Hunter
  • lance6716

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. do-not-merge/needs-triage-completed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 7, 2022
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Feb 7, 2022

/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 Feb 7, 2022
@Ehco1996 Ehco1996 added the area/dm Issues or PRs related to DM. label Feb 7, 2022
@Ehco1996 Ehco1996 changed the title savework enable test master(dm): add task manger to manger task lifecycle Feb 7, 2022
@Ehco1996 Ehco1996 changed the title master(dm): add task manger to manger task lifecycle master(dm): add task manager Feb 7, 2022
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Feb 7, 2022

/run-dm-integration-tests

@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 Feb 7, 2022
@Ehco1996 Ehco1996 changed the title master(dm): add task manager master(dm): add task/source manager Feb 13, 2022
@Ehco1996
Copy link
Contributor Author

/run-dm-integration-tests

@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 13, 2022
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 14, 2022
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 14, 2022
dm/dm/master/server.go Outdated Show resolved Hide resolved
dm/dm/master/server.go 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.

rest lgtm

dm/dm/master/server.go Outdated Show resolved Hide resolved
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Mar 2, 2022

/run-dm-integration-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.

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 2, 2022
} else if stage.Expect == pb.Stage_Paused {
op = pb.TaskOp_Pause
return opErrTypeBeforeOp, w.StartSubTask(&subTaskCfg, stage.Expect, expectValidatorStage, true)
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

st is nil, so OperateSubTask will fail. In old logic when st is nil we always call StartSubTask

Copy link
Contributor Author

@Ehco1996 Ehco1996 Mar 3, 2022

Choose a reason for hiding this comment

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

i left a comment here, this err from operateSubTask is expected, caller should not operate a task that not in subTaskHolder

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see the old logic only handles Stage_Running and Stage_Paused. But I think the logic of deciding if the expected stage is valid should be put inside StartSubTask and OperateSubTask, not in operateSubTaskStage. In other words, if the subtask exists, we simply forward expecte stage to OperateSubTask, otherwise to StartSubTask.

It's OK we change it in future.

dm/dm/worker/source_worker.go Outdated Show resolved Hide resolved
}, pb.Stage_Stopped, pb.Stage_Stopped, true), IsNil)
task = w.subTaskHolder.findSubTask("testStartTask-in-stopped")
c.Assert(task, NotNil)
c.Assert(task.Result().String(), Matches, ".*worker already closed.*")
Copy link
Contributor

Choose a reason for hiding this comment

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

may need discuss with PM, if user creates a stopped task, DM-worker should
reserve some structure in memory and paused them, or do nothing?

For example, can a stopped incremental task that will read binlog.000001 forbid relay log purging binlog.000001

Choose a reason for hiding this comment

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

I think the stopped task still have to hold the necessary binlog.

An binlog may relates with multiple tasks. Whatever it's stopped or running , the binlog it needs should not be purged.

Maybe we can offer a feature in future like support query how many tasks relate with this binlog and users can purge it forced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe later, current just do nothing

dm/dm/worker/subtask.go Outdated Show resolved Hide resolved
Ehco1996 and others added 2 commits March 3, 2022 14:01
Co-authored-by: lance6716 <lance6716@gmail.com>
} else if stage.Expect == pb.Stage_Paused {
op = pb.TaskOp_Pause
return opErrTypeBeforeOp, w.StartSubTask(&subTaskCfg, stage.Expect, expectValidatorStage, true)
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see the old logic only handles Stage_Running and Stage_Paused. But I think the logic of deciding if the expected stage is valid should be put inside StartSubTask and OperateSubTask, not in operateSubTaskStage. In other words, if the subtask exists, we simply forward expecte stage to OperateSubTask, otherwise to StartSubTask.

It's OK we change it in future.

@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 Mar 3, 2022
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Mar 3, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 5594251

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 3, 2022
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Mar 3, 2022
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Mar 3, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 7b21bf7

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

@Ehco1996: 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 3cbac21 into pingcap:master Mar 3, 2022
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/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.

7 participants