From 1d155a43adfb97e486c1378eef682b1912132005 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 11 Oct 2023 22:51:20 +0800 Subject: [PATCH] Fix data-race bug when accessing task.LastRun (#27584) --- 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,