From 83e913e487a2ec7e209bb4d4d58082c66e3dcfa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Thu, 9 Jan 2025 17:24:21 +0000 Subject: [PATCH] don't wait 10 minutes when slot still in use --- flow/workflows/cdc_flow.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/flow/workflows/cdc_flow.go b/flow/workflows/cdc_flow.go index d3bf1a7a3..d5aa4ff3d 100644 --- a/flow/workflows/cdc_flow.go +++ b/flow/workflows/cdc_flow.go @@ -10,6 +10,7 @@ import ( "time" "github.com/google/uuid" + "github.com/jackc/pgerrcode" "go.temporal.io/api/enums/v1" "go.temporal.io/sdk/log" "go.temporal.io/sdk/temporal" @@ -506,8 +507,13 @@ func CDCFlowWorkflow( } else { logger.Error("error in sync flow", slog.Any("error", err)) } - logger.Info("sync flow errored, sleeping for 10 minutes before retrying") - _ = workflow.Sleep(ctx, 10*time.Minute) + if shared.IsSQLStateError(err, pgerrcode.ObjectInUse) { + logger.Info("sync flow errored, sleeping for 1 minute before retrying") + _ = workflow.Sleep(ctx, time.Minute) + } else { + logger.Info("sync flow errored, sleeping for 10 minutes before retrying") + _ = workflow.Sleep(ctx, 10*time.Minute) + } } else { logger.Info("sync finished") }