Fix data-race bug when accessing task.LastRun (#27584) (#27586)

Backport #27584 by @wxiaoguang

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot 2023-10-11 23:27:38 +08:00 committed by GitHub
parent 7ec7c733c7
commit 844ab9a441
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,12 +107,11 @@ func ListTasks() TaskTable {
prev = e.PreviousRun()
}
task.lock.Lock()
// If the manual run is after the cron run, use that instead.
if prev.Before(task.LastRun) {
prev = task.LastRun
}
task.lock.Lock()
tTable = append(tTable, &TaskTableRow{
Name: task.Name,
Spec: spec,