Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetChildWorkflowExecution().Get(...) panics on duplicated ID #933

Open
mfateev opened this issue Jan 27, 2020 · 0 comments
Open

GetChildWorkflowExecution().Get(...) panics on duplicated ID #933

mfateev opened this issue Jan 27, 2020 · 0 comments
Labels

Comments

@mfateev
Copy link
Contributor

mfateev commented Jan 27, 2020

ExecuteChildWorkflow(...).GetChildWorkflowExecution(..).Get(...) panics if the child workflow with the same ID is already running:

2020-01-27T08:22:07.355-0800	ERROR	internal/internal_task_handlers.go:1342	Workflow panic.	{"Domain": "samples-domain", "TaskList": "childWorkflowGroup", "WorkerID": "[email protected]@childWorkflowGroup", "WorkflowID": "parentworkflow_7934c636-0cda-4706-b654-d12f2578825e", "RunID": "a1557a7e-34ad-46b3-94fa-cbe1d918c4c4", "PanicError": "adding duplicate decision DecisionType: ChildWorkflow, ID: child_workflow:a1557a7e-34ad-46b3-94fa-cbe1d918c4c4, state=Created, isDone()=false, history=[Created]", "PanicStack": "coroutine 1 [panic]:\ngo.uber.org/cadence/internal.panicIllegalState(...)\n\t/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_decision_state_machine.go:332\ngo.uber.org/cadence/internal.(*decisionsHelper).addDecision(0xc0004e85d0, 0x197f920, 0xc0000e55a0)\n\t/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_decision_state_machine.go:708 +0x1f3\ngo.uber.org/cadence/internal.(*decisionsHelper).startChildWorkflowExecution(0xc0004e85d0, 0xc0000fe870, 0x15ddbe8, 0xc0004e89c0)\n\t/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_decision_state_machine.go:829 +0x59\ngo.uber.org/cadence/internal.(*workflowEnvironmentImpl).ExecuteChildWorkflow(0xc0000c2000, 0xc0000e5170, 0xc0000e6150, 0xc0000e61b8, 0xc0000e5160, 0xc0002d4100, 0x33, 0x0, 0xc0004e8900, 0xc0004e8930, ...)\n\t/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_event_handlers.go:358 +0x286\ngo.uber.org/cadence/internal.ExecuteChildWorkflow(0x1974080, 0xc0004e8c90, 0x1752660, 0x187f5e8, 0xc00051c7c0, 0x2, 0x2, 0x1973ec0, 0xc0000e50c0)\n\t/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/workflow.go:585 +0x6fc\ngo.uber.org/cadence/workflow.ExecuteChildWorkflow(...)\n\t/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/workflow/workflow.go:177\nmain.SampleParentWorkflow(0x1973e80, 0xc00037c340, 0x0, 0x0)\n\t/Users/maxim/cadence/cadence-samples/cmd/samples/recipes/childworkflow/parent_workflow.go:40 +0x308\nreflect.Value.call(0x1722b40, 0x187f5f0, 0x13, 0x183dd73, 0x4, 0xc00039fe30, 0x1, 0x1, 0x1631c40, 0xc0004e8ae0, ...)\n\t/usr/local/go/src/reflect/value.go:460 +0x5f6\nreflect.Value.Call(0x1722b40, 0x187f5f0, 0x13, 0xc00039fe30, 0x1, 0x1, 0x0, 0x0, 0x0)\n\t/usr/local/go/src/reflect/value.go:321 +0xb4\ngo.uber.org/cadence/internal.(*workflowExecutor).Execute(0xc00051c320, 0x1973e80, 0xc00037c340, 0x0, 0x0, 0x0, 0xc000393701, 0x1020101, 0xc0003936f0, 0x1615418, ...)\n\t/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_worker.go:897 +0x38b\ngo.uber.org/cadence/internal.(*syncWorkflowDefinition).Execute.func1(0x1974080, 0xc0004e8ae0)\n\t/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_workflow.go:414 +0x105"}
go.uber.org/cadence/internal.(*workflowTaskHandlerImpl).completeWorkflow
	/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_task_handlers.go:1342
go.uber.org/cadence/internal.(*workflowExecutionContextImpl).CompleteDecisionTask
	/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_task_handlers.go:987
go.uber.org/cadence/internal.(*workflowExecutionContextImpl).ProcessWorkflowTask
	/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_task_handlers.go:854
go.uber.org/cadence/internal.(*workflowTaskHandlerImpl).ProcessWorkflowTask
	/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_task_handlers.go:684
go.uber.org/cadence/internal.(*workflowTaskPoller).processWorkflowTask
	/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_task_pollers.go:262
go.uber.org/cadence/internal.(*workflowTaskPoller).ProcessTask
	/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_task_pollers.go:235
go.uber.org/cadence/internal.(*baseWorker).processTask
	/Users/maxim/go/pkg/mod/go.uber.org/[email protected]/internal/internal_worker_base.go:301

Here is the code to reproduce:

func SampleParentWorkflow(ctx workflow.Context) error {
	logger := workflow.GetLogger(ctx)
	execution := workflow.GetInfo(ctx).WorkflowExecution
	// Parent workflow can choose to specify it's own ID for child execution.  Make sure they are unique for each execution.
	childID := fmt.Sprintf("child_workflow:%v", execution.RunID)
	cwo := workflow.ChildWorkflowOptions{
		// Do not specify WorkflowID if you want cadence to generate a unique ID for child execution
		WorkflowID:                   childID,
		ExecutionStartToCloseTimeout: time.Minute,
	}
	ctx = workflow.WithChildOptions(ctx, cwo)
	var result string
	workflow.ExecuteChildWorkflow(ctx, SampleChildWorkflow, 0, 5)
	workflow.Sleep(ctx, time.Second)
	f := workflow.ExecuteChildWorkflow(ctx, SampleChildWorkflow, 0, 5)
	f.GetChildWorkflowExecution().Get(ctx, nil)
	err := f.Get(ctx, &result)
	if err != nil {
		logger.Error("Parent execution received child execution failure.", zap.Error(err))
		return err
	}

	logger.Info("Parent execution completed.", zap.String("Result", result))
	return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants