From 24c356fd1974c5252509a6ce09bd72f94ebc8bef Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 24 Jun 2021 10:51:55 -0700 Subject: [PATCH] fix: hold the task worker lock when starting task workers Otherwise, we could try to shutdown at the same time and race. --- internal/decision/engine.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/decision/engine.go b/internal/decision/engine.go index 6950f59e..f7b0076f 100644 --- a/internal/decision/engine.go +++ b/internal/decision/engine.go @@ -235,6 +235,9 @@ func (e *Engine) StartWorkers(ctx context.Context, px process.Process) { e.bsm.start(px) e.startScoreLedger(px) + e.taskWorkerLock.Lock() + defer e.taskWorkerLock.Unlock() + for i := 0; i < e.taskWorkerCount; i++ { px.Go(func(px process.Process) { e.taskWorker(ctx)