Skip to content

Commit

Permalink
Pass errors to the child workflow execution future
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Mar 11, 2023
1 parent e047c84 commit de4a037
Show file tree
Hide file tree
Showing 7 changed files with 580 additions and 1 deletion.
9 changes: 9 additions & 0 deletions internal/internal_event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,17 @@ func (wc *workflowEnvironmentImpl) ExecuteChildWorkflow(
}
memo, err := getWorkflowMemo(params.Memo, wc.dataConverter)
if err != nil {
if wc.sdkFlags.tryUse(SDKFlagChildWorkflowErrorExecution, !wc.isReplay) {
startedHandler(WorkflowExecution{}, &ChildWorkflowExecutionAlreadyStartedError{})
}
callback(nil, err)
return
}
searchAttr, err := serializeSearchAttributes(params.SearchAttributes)
if err != nil {
if wc.sdkFlags.tryUse(SDKFlagChildWorkflowErrorExecution, !wc.isReplay) {
startedHandler(WorkflowExecution{}, &ChildWorkflowExecutionAlreadyStartedError{})
}
callback(nil, err)
return
}
Expand All @@ -506,6 +512,9 @@ func (wc *workflowEnvironmentImpl) ExecuteChildWorkflow(

command, err := wc.commandsHelper.startChildWorkflowExecution(attributes)
if _, ok := err.(*childWorkflowExistsWithId); ok {
if wc.sdkFlags.tryUse(SDKFlagChildWorkflowErrorExecution, !wc.isReplay) {
startedHandler(WorkflowExecution{}, &ChildWorkflowExecutionAlreadyStartedError{})
}
callback(nil, &ChildWorkflowExecutionAlreadyStartedError{})
return
}
Expand Down
7 changes: 6 additions & 1 deletion internal/internal_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ const (
// LimitChangeVersionSASize will limit the search attribute size of TemporalChangeVersion to 2048 when
// calling GetVersion. If the limit is exceeded the search attribute is not updated.
SDKFlagLimitChangeVersionSASize = 1
SDKFlagUnknown = math.MaxUint32
// LimitChangeVersionSASize return errors to child workflow execution future if the child workflow would
// fail in the synchronous path.
SDKFlagChildWorkflowErrorExecution = 2
SDKFlagUnknown = math.MaxUint32
)

func sdkFlagFromUint(value uint32) sdkFlag {
Expand All @@ -46,6 +49,8 @@ func sdkFlagFromUint(value uint32) sdkFlag {
return SDKFlagUnset
case uint32(SDKFlagLimitChangeVersionSASize):
return SDKFlagLimitChangeVersionSASize
case uint32(SDKFlagChildWorkflowErrorExecution):
return SDKFlagChildWorkflowErrorExecution
default:
return SDKFlagUnknown
}
Expand Down
10 changes: 10 additions & 0 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,16 @@ func (ts *IntegrationTestSuite) TestChildWorkflowDuplicatePanic_Regression() {
ts.NoError(err)
}

func (ts *IntegrationTestSuite) TestChildWorkflowDuplicateGetExecutionStuck_Regression() {
wfid := "test-child-workflow-duplicate-get-execution-stuck-regression"
run, err := ts.client.ExecuteWorkflow(context.Background(),
ts.startWorkflowOptions(wfid),
ts.workflows.ChildWorkflowDuplicateGetExecutionStuckRepro)
ts.NoError(err)
err = run.Get(context.Background(), nil)
ts.NoError(err)
}

func (ts *IntegrationTestSuite) TestCancelActivityImmediately() {
var expected []string
err := ts.executeWorkflow("test-cancel-activity-immediately", ts.workflows.CancelActivityImmediately, &expected)
Expand Down
Loading

0 comments on commit de4a037

Please sign in to comment.