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

ttl: reschedule scan tasks after update task state #39891

Merged
merged 7 commits into from
Dec 13, 2022
13 changes: 10 additions & 3 deletions ttl/ttlworker/job_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ func (m *JobManager) jobLoop() error {
}
cancel()
case <-updateScanTaskStateTicker:
m.updateTaskState()
if m.updateTaskState() {
m.rescheduleJobs(se, now)
}
case <-m.notifyStateCh:
m.updateTaskState()
if m.updateTaskState() {
m.rescheduleJobs(se, now)
}
case <-jobCheckTicker:
m.checkFinishedJob(se, now)
m.checkNotOwnJob()
Expand Down Expand Up @@ -229,7 +233,8 @@ func (m *JobManager) resizeWorkers(workers []worker, count int, factory func() w
return workers, nil
}

func (m *JobManager) updateTaskState() {
// updateTaskState polls the result from scan worker and returns whether there are result polled
func (m *JobManager) updateTaskState() bool {
results := m.pollScanWorkerResults()
for _, result := range results {
job := findJobWithTableID(m.runningJobs, result.task.tbl.ID)
Expand All @@ -240,6 +245,8 @@ func (m *JobManager) updateTaskState() {
job.scanTaskErr = multierr.Append(job.scanTaskErr, result.err)
}
}

return len(results) > 0
}

func (m *JobManager) pollScanWorkerResults() []*ttlScanTaskExecResult {
Expand Down