# Workflow command not getting executed when batched with last WorkflowTaskCompleted?

**URL:** https://community.temporal.io/t/workflow-command-not-getting-executed-when-batched-with-last-workflowtaskcompleted/8204
**Category:** Community Support
**Tags:** go-sdk, child-workflow, workflow-implementat
**Created:** [May 9, 2023, 4:20pm UTC](https://community.temporal.io/t/workflow-command-not-getting-executed-when-batched-with-last-workflowtaskcompleted/8204 "2023-05-09T16:20:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nitesh237](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/nitesh237/32/1656_2.png) [@nitesh237](https://community.temporal.io/u/nitesh237)
#### Post date: [May 9, 2023, 4:20pm UTC](https://community.temporal.io/t/workflow-command-not-getting-executed-when-batched-with-last-workflowtaskcompleted/8204/1 "2023-05-09T16:20:19Z")

</div>

Hi Team,

We had a use-case where we wanted to use a workflow to launch multiple child workflows and terminate the parent workflow. There we were facing a weird behaviour and we don’t if its a bug or a conscious call in the temporal’s design. Can you please help in understanding this behaviour better ?

**Issue Description**  
We know temporal’s SDK does batch the commands generated from the workflow until it can’t make any further progress, beyond which the commands are sent to the temporal server for execution. However, if the commands are batched with the last `WorkflowTaskCompleted ` beyond which `WorkflowExecutionCompleted` event is generated, we are not seeing any command execution.

**How to Reproduce**  
To show case this I have modified the [child-workflow](https://github.com/temporalio/samples-go/tree/main/child-workflow) example in the go-samples.

```auto
func SampleParentWorkflow(ctx workflow.Context) (string, error) {
	logger := workflow.GetLogger(ctx)

	var result string
	// var future workflow.ChildWorkflowFuture

	for i := 0; i < 10; i++ {
		cwo := workflow.ChildWorkflowOptions{
			WorkflowID: "child-workflow-" + strconv.Itoa(i),
			WorkflowIDReusePolicy: enums.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE,
			ParentClosePolicy: enums.PARENT_CLOSE_POLICY_ABANDON,
		}

		_ = workflow.ExecuteChildWorkflow(workflow.WithChildOptions(ctx, cwo), SampleChildWorkflow, "World")
	}

	logger.Info("Parent execution completed.", "Result", result)
	return result, nil
}

```

**What We Expected**  
The parent workflow execution should finish and result in orphan child workflow executions.

**What We Saw Instead**  
The parent workflow execution terminates and child workflows aren’t spawned by the temporal servers.

 ![Screenshot 2023-05-09 at 9.35.50 PM](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/9/9400d6e804fd7453e863f19f04c2bf38490e3264.jpeg)

 ![Screenshot 2023-05-09 at 9.35.58 PM](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/e/e3d2114cff581553fd3a308f09bb97a62227956e.png)

**What Lead To Expected Behaviour**  
However, if we place a blocking call at the end of workflow e.g. `workflow.Sleep(ctx, 2*time.Millisecond)` or wait on one of the child workflow future, the child workflow executions are proceeding.

 ![Screenshot 2023-05-09 at 9.45.24 PM](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/9/96cd42044db6156ab5044840dcd6e5cff8ec433f.png)  
In fact, we saw parent workflow task execution failed in the middle with an error `UnhandledCommand`.  
 ![Screenshot 2023-05-09 at 9.46.05 PM](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/2/26d51e8bc3f36abdd2ad0cbc506c12c1615e7283.png)

---

<div class="post-metadata">

### Author: ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)
#### Post date: [May 13, 2023, 4:43pm UTC](https://community.temporal.io/t/workflow-command-not-getting-executed-when-batched-with-last-workflowtaskcompleted/8204/2 "2023-05-13T16:43:33Z")

</div>

> [@Best way to create an async child workflow](https://community.temporal.io/t/best-way-to-create-an-async-child-workflow/114/2):
>
> Currently, it is not straightforward. We have plans to improve the experience ([relevant issue](https://github.com/temporalio/temporal-java-sdk/issues/74)), but in the meantime, the following should be done. Java SDK Set ChildWorkflowOptions.ParentClosePolicy to ABANDON when creating a child workflow stub. Start child workflow asynchronously using Async.function or Async.procedure. Call Workflow.getWorkflowExecution(…) on the child stub Wait for the Promise returned by getWorkflowExecution to complete. This indicates that the child successfully started …

---

<div class="post-metadata">

### Author: ![nitesh237](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/nitesh237/32/1656_2.png) [@nitesh237](https://community.temporal.io/u/nitesh237)
#### Post date: [May 17, 2023, 11:51am UTC](https://community.temporal.io/t/workflow-command-not-getting-executed-when-batched-with-last-workflowtaskcompleted/8204/3 "2023-05-17T11:51:08Z")

</div>

Got it. I was not aware of this existing post. I would like to volunteer to solve this issue if possible. Let me know if I can be of any help.

---

<div class="post-metadata">

### Author: ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)
#### Post date: [May 17, 2023, 4:20pm UTC](https://community.temporal.io/t/workflow-command-not-getting-executed-when-batched-with-last-workflowtaskcompleted/8204/4 "2023-05-17T16:20:58Z")

</div>

This requires a pretty intrusive change in the history service. So it is not a simple contribution to make.
