Skip to content

Commit b52418e

Browse files
[FIX] refactor task concurrency locking logic
1 parent 289689d commit b52418e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

queue/task.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,9 @@ func (s *TaskScheduler) runTask(ctx context.Context, task *Task) {
582582
Field("task_name", task.Name).
583583
Msg("failed to update next run time before execution")
584584
}
585-
} else {
585+
}
586+
587+
if !task.AllowConcurrent {
586588
task.mutex.Lock()
587589
task.IsRunning = true
588590
task.UpdatedAt = time.Now()
@@ -644,7 +646,9 @@ func (s *TaskScheduler) runTask(ctx context.Context, task *Task) {
644646
nextRunTime = task.NextRun
645647
runCount = task.RunCount
646648
task.mutex.RUnlock()
647-
} else {
649+
}
650+
651+
if task.AllowConcurrent {
648652
nextRunTime = task.NextRun
649653
runCount = task.RunCount
650654
task.mutex.Unlock()
@@ -708,7 +712,9 @@ func (s *TaskScheduler) runTask(ctx context.Context, task *Task) {
708712
task.mutex.RLock()
709713
nextRunTime = task.NextRun
710714
task.mutex.RUnlock()
711-
} else {
715+
}
716+
717+
if task.AllowConcurrent {
712718
nextRunTime = task.NextRun
713719
task.mutex.Unlock()
714720
}

0 commit comments

Comments
 (0)