From 844ab9a4416b8c01772396663cd1b2cfaad8d0cf Mon Sep 17 00:00:00 2001 From: Giteabot Date: Wed, 11 Oct 2023 23:27:38 +0800 Subject: [PATCH] Fix data-race bug when accessing task.LastRun (#27584) (#27586) Backport #27584 by @wxiaoguang Co-authored-by: wxiaoguang --- services/cron/cron.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/cron/cron.go b/services/cron/cron.go index 63db75ab3b..3c5737e371 100644 --- a/services/cron/cron.go +++ b/services/cron/cron.go @@ -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,