-
Notifications
You must be signed in to change notification settings - Fork 288
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/worker(dm): suppport update config when task not run #4760
master/worker(dm): suppport update config when task not run #4760
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
} | ||
w.cfg = sourceCfg | ||
// we need update config from etcd first in case this cfg is updated by master | ||
if refreshErr := w.refreshSourceCfg(); refreshErr != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we only need to refresh when user want to enable-relay or restart task for source
dm/dm/worker/source_worker.go
Outdated
failpoint.Inject("SkipRefreshFromETCDInUT", func(_ failpoint.Value) { | ||
failpoint.Goto("bypassRefresh") | ||
}) | ||
if op == pb.TaskOp_Resume || op == pb.TaskOp_AutoResume { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when user want to restart or start a stopped task, use the newest cfg from etcd.
dynamic update will impl later
dm/dm/master/scheduler/scheduler.go
Outdated
@@ -1039,6 +1027,63 @@ func (s *Scheduler) RemoveSubTasks(task string, sources ...string) error { | |||
return nil | |||
} | |||
|
|||
// UpdateSubTasks update the information of one or more subtasks for one task. | |||
// now only support update a task that not in running stage. | |||
func (s *Scheduler) UpdateSubTasks(cfgs ...config.SubTaskConfig) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need check if this field is safe to updated, also need to check current unit with this subtask check this in worker or master? if checked in worekr i need to added new rpc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actully we can check this just on master side
no we need send request to worker to check the current task unit anyway.... so we better just do this check on worker side
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## master #4760 +/- ##
================================================
+ Coverage 55.6402% 55.7138% +0.0736%
================================================
Files 494 521 +27
Lines 61283 64930 +3647
================================================
+ Hits 34098 36175 +2077
- Misses 23750 25201 +1451
- Partials 3435 3554 +119 |
/run-dm-integration-tests |
/run-dm-integration-tests |
/run-dm-integration-tests |
/run-dm-integration-tests |
1 similar comment
/run-dm-integration-tests |
/run-dm-integration-tests |
1 similar comment
/run-dm-integration-tests |
dm/dm/master/scheduler/scheduler.go
Outdated
// 3. check this cfg is ok to update. | ||
if !checkSourceCfgCanUpdated(s.sourceCfgs[cfg.SourceID], cfg) { | ||
return terror.ErrSchedulerSourceCfgUpdate.Generate() | ||
// 3. check if there is relay workers for this source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember since v5.4, source config with enable-relay: true will not record a relay worker. Should we also allow update for this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now use expectRelayStages to check if this source is enable relay, seems this can avoid this case
return terror.ErrSchedulerNotStarted.Generate() | ||
} | ||
if len(cfgs) == 0 { | ||
return nil // no subtasks need to add, this should not happen. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can change the function parameter to (context, SubTaskConfig, ...SubTaskConfig) to tell the compiler there must be at least one SubTaskConfig.
OK to not change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can't find the example of how to use unnamed paramaters , how can i refer the unnamed stcfgs
?
seems the only use of unnamed parameters is when you have to define a function with a specific
https://stackoverflow.com/questions/24000305/how-to-refer-to-an-unnamed-function-argument-in-go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(context, ...SubTaskConfig) -> (context, SubTaskConfig, ...SubTaskConfig)
/run-dm-integration-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest lgtm
/run-dm-integration-tests |
/run-verify |
func (s *Syncer) CheckCanUpdateCfg(newCfg *config.SubTaskConfig) error { | ||
s.RLock() | ||
defer s.RUnlock() | ||
// can't update when in sharding merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in some optimistic case, like partially drop column, BAlist should also not be updated
@GMHDBJD PTAL, can you list the forbidden cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's hard to list or check all the case ... maybe let the user to bear the risk of changing config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also remember to add this limitation to doc
Co-authored-by: lance6716 <lance6716@gmail.com>
/run-dm-integration-tests |
dm/dm/worker/server_test.go
Outdated
@@ -640,3 +664,80 @@ func loadSourceConfigWithoutPassword(c *C) *config.SourceConfig { | |||
sourceCfg.From.Password = "" // no password set | |||
return sourceCfg | |||
} | |||
|
|||
func (t *testServer) testSourceWorker(c *C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why move it? the content of this function is related to source worker, so it's natural to put it in source_worker_test.go
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 6074849
|
What problem does this PR solve?
Issue Number: ref #4484
What is changed and how it works?
for master:
addthis will added in next prenable
filed in source cfg for later usefor worker
CheckSubtasksCanUpdate
for masterbut there is no call now, just inter logic
Check List
Tests
Code changes
Side effects
Related changes
Release note