# Childflows replay due the mainflow replay

**URL:** https://community.temporal.io/t/childflows-replay-due-the-mainflow-replay/2575
**Category:** Community Support
**Tags:** child-workflow
**Created:** [July 17, 2021, 11:44am UTC](https://community.temporal.io/t/childflows-replay-due-the-mainflow-replay/2575 "2021-07-17T11:44:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ramprasad\_Indarapu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramprasad_indarapu/32/718_2.png) [@Ramprasad\_Indarapu](https://community.temporal.io/u/Ramprasad_Indarapu)
#### Post date: [July 17, 2021, 11:44am UTC](https://community.temporal.io/t/childflows-replay-due-the-mainflow-replay/2575/1 "2021-07-17T11:44:30Z")

</div>

We are doing some performance testing

We have a main flow running child flows in parallel using the below code

```java
workflow = Workflow.newChildWorkflowStub(JiffyWorkflow.class);
Promise<String> asyncResult =
    Async.function(workflow::execute, flowInput);

String subFlowResult = asyncResult.get();

```

When one of the child flow is in execution, the parent work flow got WorkflowTaskTimedOut, event which is causing replay of the parent flow and it is trying to re-trigger the child flow.  
But as the child flow is already running(with the same id), it failed with below exception

```auto
{
  "message": "Failure handling event 5 of 'EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED' type. IsReplaying=true, PreviousStartedEventId=3, workflowTaskStartedEventId=12, Currently Processing StartedEventId=3",
  "source": "JavaSDK",
  "stackTrace": "io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:193)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleEvent(ReplayWorkflowRunTaskHandler.java:140)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTaskImpl(ReplayWorkflowRunTaskHandler.java:180)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTask(ReplayWorkflowRunTaskHandler.java:150)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTaskWithEmbeddedQuery(ReplayWorkflowTaskHandler.java:201)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTask(ReplayWorkflowTaskHandler.java:114)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:319)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:279)
io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:73)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base/java.lang.Thread.run(Thread.java:832)
",
  "cause": {
    "message": "Event 5 of EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED does not match command COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION",
    "source": "JavaSDK",
    "stackTrace": "io.temporal.internal.statemachines.WorkflowStateMachines.handleCommandEvent(WorkflowStateMachines.java:263)
io.temporal.internal.statemachines.WorkflowStateMachines.handleEventImpl(WorkflowStateMachines.java:199)
io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:178)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleEvent(ReplayWorkflowRunTaskHandler.java:140)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTaskImpl(ReplayWorkflowRunTaskHandler.java:180)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTask(ReplayWorkflowRunTaskHandler.java:150)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTaskWithEmbeddedQuery(ReplayWorkflowTaskHandler.java:201)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTask(ReplayWorkflowTaskHandler.java:114)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:319)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:279)
io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:73)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base/java.lang.Thread.run(Thread.java:832)
",
    "cause": null,
    "applicationFailureInfo": {
      "type": "java.lang.IllegalStateException",
      "nonRetryable": false,
      "details": null
    },
    "failureInfo": "applicationFailureInfo"
  },
  "applicationFailureInfo": {
    "type": "io.temporal.internal.replay.InternalWorkflowTaskException",
    "nonRetryable": false,
    "details": null
  },
  "failureInfo": "applicationFailureInfo"
}

```

What is the best way to handle the same?

---

<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: [July 17, 2021, 7:41pm UTC](https://community.temporal.io/t/childflows-replay-due-the-mainflow-replay/2575/2 "2021-07-17T19:41:02Z")

</div>

I don’t think it is related to the workflow already running. The error looks like a non deterministic workflow code error. The most common cause is a deployment of code changes not protected by  
`getVersion` API.

Make sure that the workflow code obeys all the [constraints](https://docs.temporal.io/docs/java/workflows#workflow-implementation-constraints) outlined in the documentation.
