Skip to content

Commit

Permalink
don't wait 10 minutes when slot still in use
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Jan 9, 2025
1 parent 980eb42 commit 83e913e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions flow/workflows/cdc_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 83e913e

Please sign in to comment.