From 7a102daba67feec71680af642a8f4904ded8c95a Mon Sep 17 00:00:00 2001 From: John Roesler Date: Wed, 20 Sep 2023 19:47:09 -0500 Subject: [PATCH] reschedule limit mode was broken - fixing the inc/dec (#572) --- executor.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/executor.go b/executor.go index 8e20f5e1..8dea17c3 100644 --- a/executor.go +++ b/executor.go @@ -154,6 +154,11 @@ func (e *executor) start() { } func (e *executor) runJob(f jobFunction) { + defer func() { + if e.limitMode == RescheduleMode && e.limitModeMaxRunningJobs > 0 { + e.limitModeRunningJobs.Add(-1) + } + }() switch f.runConfig.mode { case defaultMode: lockKey := f.jobName @@ -244,6 +249,7 @@ func (e *executor) run() { if e.limitModeRunningJobs.Load() < int64(e.limitModeMaxRunningJobs) { select { case e.limitModeQueue <- f: + e.limitModeRunningJobs.Inc() case <-e.ctx.Done(): } }