Skip to content

Commit 844ab9a

Browse files
GiteaBotwxiaoguang
andauthored
Fix data-race bug when accessing task.LastRun (#27584) (#27586)
Backport #27584 by @wxiaoguang Co-authored-by: wxiaoguang <[email protected]>
1 parent 7ec7c73 commit 844ab9a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

services/cron/cron.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,11 @@ func ListTasks() TaskTable {
107107
prev = e.PreviousRun()
108108
}
109109

110+
task.lock.Lock()
110111
// If the manual run is after the cron run, use that instead.
111112
if prev.Before(task.LastRun) {
112113
prev = task.LastRun
113114
}
114-
115-
task.lock.Lock()
116115
tTable = append(tTable, &TaskTableRow{
117116
Name: task.Name,
118117
Spec: spec,

0 commit comments

Comments
 (0)