Skip to content

Commit c875ec0

Browse files
committed
should not use uncancellable contexts for retry itself
1 parent 7df56b6 commit c875ec0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

dbos/workflow.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
807807
// Register a cancel function that cancels the workflow in the DB as soon as the context is cancelled
808808
dbosCancelFunction := func() {
809809
c.logger.Info("Cancelling workflow", "workflow_id", workflowID)
810-
err = retry(uncancellableCtx, func() error {
810+
err = retry(c, func() error {
811811
return c.systemDB.cancelWorkflow(uncancellableCtx, workflowID)
812812
}, withRetrierLogger(c.logger))
813813
if err != nil {
@@ -845,7 +845,7 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
845845
var dbosErr *DBOSError
846846
if errors.As(err, &dbosErr) && dbosErr.Code == ConflictingIDError {
847847
c.logger.Warn("Workflow ID conflict detected. Waiting for existing workflow to complete", "workflow_id", workflowID)
848-
result, err = retryWithResult(uncancellableCtx, func() (any, error) {
848+
result, err = retryWithResult(c, func() (any, error) {
849849
return c.systemDB.awaitWorkflowResult(uncancellableCtx, workflowID)
850850
}, withRetrierLogger(c.logger))
851851
} else {
@@ -863,7 +863,7 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
863863
status = WorkflowStatusCancelled
864864
}
865865

866-
recordErr := retry(uncancellableCtx, func() error {
866+
recordErr := retry(c, func() error {
867867
return c.systemDB.updateWorkflowOutcome(uncancellableCtx, updateWorkflowOutcomeDBInput{
868868
workflowID: workflowID,
869869
status: status,
@@ -1067,7 +1067,7 @@ func (c *dbosContext) RunAsStep(_ DBOSContext, fn StepFunc, opts ...StepOption)
10671067
uncancellableCtx := WithoutCancel(c)
10681068

10691069
// Check the step is cancelled, has already completed, or is called with a different name
1070-
recordedOutput, err := retryWithResult(uncancellableCtx, func() (*recordedResult, error) {
1070+
recordedOutput, err := retryWithResult(c, func() (*recordedResult, error) {
10711071
return c.systemDB.checkOperationExecution(uncancellableCtx, checkOperationExecutionDBInput{
10721072
workflowID: stepState.workflowID,
10731073
stepID: stepState.stepID,
@@ -1136,7 +1136,7 @@ func (c *dbosContext) RunAsStep(_ DBOSContext, fn StepFunc, opts ...StepOption)
11361136
err: stepError,
11371137
output: stepOutput,
11381138
}
1139-
recErr := retry(uncancellableCtx, func() error {
1139+
recErr := retry(c, func() error {
11401140
return c.systemDB.recordOperationResult(uncancellableCtx, dbInput)
11411141
}, withRetrierLogger(c.logger))
11421142
if recErr != nil {

0 commit comments

Comments
 (0)