From 52756ab83ec958a8492cfa8c734f210bad39b880 Mon Sep 17 00:00:00 2001 From: Bevan Arps Date: Thu, 2 Mar 2023 13:53:38 +1300 Subject: [PATCH] Fix deadlock issue with `run: once` (#1025) --- task.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/task.go b/task.go index 7a0d3ffd..24adb1ba 100644 --- a/task.go +++ b/task.go @@ -342,11 +342,15 @@ func (e *Executor) startExecution(ctx context.Context, t *taskfile.Task, execute } e.executionHashesMutex.Lock() - otherExecutionCtx, ok := e.executionHashes[h] - if ok { + if otherExecutionCtx, ok := e.executionHashes[h]; ok { e.executionHashesMutex.Unlock() e.Logger.VerboseErrf(logger.Magenta, "task: skipping execution of task: %s", h) + + // Release our execution slot to avoid blocking other tasks while we wait + reacquire := e.releaseConcurrencyLimit() + defer reacquire() + <-otherExecutionCtx.Done() return nil }