From f850265c1e821bdd0dbf2333074f965564dc0098 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Mon, 6 Oct 2025 16:39:55 +0530 Subject: [PATCH] add a random sleep so no two worker check cache at same time --- functions/onprem/worker/worker.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/functions/onprem/worker/worker.go b/functions/onprem/worker/worker.go index 6797ff3c..752eca62 100644 --- a/functions/onprem/worker/worker.go +++ b/functions/onprem/worker/worker.go @@ -3874,6 +3874,12 @@ func sendAppRequest(ctx context.Context, incomingUrl, appName string, port int, // Checking as LATE as possible, ensuring we don't rerun what's already ran // ctx = context.Background() + + // Sleep between 0 and 250 ms for randomness so no same worker check at same time (same as cloud) + rand.Seed(time.Now().UnixNano()) + randMs := rand.Intn(250) + time.Sleep(time.Duration(randMs) * time.Millisecond) + newExecId := fmt.Sprintf("%s_%s", workflowExecution.ExecutionId, action.ID) _, err = shuffle.GetCache(ctx, newExecId) if err == nil {