Parent and child workflow close policy

The docs state:

When a parent workflow is cancelled by the user, the child workflow can be cancelled or abandoned based on a configurable child policy.

If the policy is to cancel child workflows; what happens if the parent workflow returns an error? Do the children also terminate?

I believe ChildWorkflowClose policy was never implemented and is not even available at least in Temporal. Instead ParentClosePolicy was introduced. It defines child behavior in case of parent completion. This allows specifying different policies for different children.

The behavior of the child doesn’t depend on the reason the parent completed. So it doesn’t matter if the parent completed successfully, failed, or timed out. The child will be affected according to the policy:

  • PARENT_CLOSE_POLICY_TERMINATE: child workflow is terminated
  • PARENT_CLOSE_POLICY_ABANDON: the child is not notified about parent completion
  • PARENT_CLOSE_POLICY_REQUEST_CANCEL: the child gets the cancellation request

There is one more concept that applies to the parent-child relationship. A parent can request a child cancellation by canceling context passed to the ExecuteChildWorkflow call. The WaitFoCancellation parameter defines if the future returned from the ExecuteChildWorkflow becomes ready immediately or only after the child completes its execution.

1 Like