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

ddl: fix taskNodes temporarily #46671

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion disttask/framework/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@

func (d *dispatcher) replaceDeadNodesIfAny() error {
if len(d.taskNodes) == 0 {
return errors.Errorf("len(d.taskNodes) == 0, onNextStage is not invoked before onRunning")
var err error
d.taskNodes, err = d.taskMgr.GetSchedulerIDsByTaskIDAndStep(d.task.ID, d.task.Step)
if err != nil {
return err

Check warning on line 253 in disttask/framework/dispatcher/dispatcher.go

View check run for this annotation

Codecov / codecov/patch

disttask/framework/dispatcher/dispatcher.go#L250-L253

Added lines #L250 - L253 were not covered by tests
}
}
d.liveNodeFetchTick++
if d.liveNodeFetchTick == d.liveNodeFetchInterval {
Expand Down
20 changes: 20 additions & 0 deletions disttask/framework/storage/task_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,26 @@
return instanceIDs, nil
}

// GetSchedulerIDsByTaskIDAndStep gets the scheduler IDs of the given global task ID and step.
func (stm *TaskManager) GetSchedulerIDsByTaskIDAndStep(taskID int64, step int64) ([]string, error) {
rs, err := stm.executeSQLWithNewSession(stm.ctx, `select distinct(exec_id) from mysql.tidb_background_subtask
where task_key = %? and step = %?`, taskID, step)
if err != nil {
return nil, err
}
if len(rs) == 0 {
return nil, nil
}

instanceIDs := make([]string, 0, len(rs))
for _, r := range rs {
id := r.GetString(0)
instanceIDs = append(instanceIDs, id)
}

return instanceIDs, nil

Check warning on line 531 in disttask/framework/storage/task_table.go

View check run for this annotation

Codecov / codecov/patch

disttask/framework/storage/task_table.go#L515-L531

Added lines #L515 - L531 were not covered by tests
}

Check warning on line 533 in disttask/framework/storage/task_table.go

View check run for this annotation

Codecov / codecov/patch

disttask/framework/storage/task_table.go#L533

Added line #L533 was not covered by tests
// IsSchedulerCanceled checks if subtask 'execID' of task 'taskID' has been canceled somehow.
func (stm *TaskManager) IsSchedulerCanceled(taskID int64, execID string) (bool, error) {
rs, err := stm.executeSQLWithNewSession(stm.ctx, "select 1 from mysql.tidb_background_subtask where task_key = %? and exec_id = %?", taskID, execID)
Expand Down