temporal icon indicating copy to clipboard operation
temporal copied to clipboard

Add ability to transfer child workflows to new parent run when parent calls continue as new

Open tsurdilo opened this issue 2 years ago • 7 comments

Request: Add ability to transfer child workflows to new parent run when parent calls continue as new.

Currently the child workflow is not transferred and follows the parentClosePolicy.

tsurdilo avatar Mar 14 '22 18:03 tsurdilo

@tsurdilo Can you clarify what "transfer child workflows" would mean in practice?

Today, upon continue as new, do child workflows continue to follow the parentClosePolicy or are they effectively abandoned?

albertyfwu avatar Jun 22 '22 16:06 albertyfwu

Today, it seems that with the default PARENT_CLOSE_POLICY_TERMINATE, children are terminated if the parent workflow continues as new. Until there is a built-in way to handle transfer of children to the next WF run, I'm doing the following:

  • Save an array/map pendingChildren of all running children in the parent worklfow
  • Pass workflowIds to the next run, as an argument of the continueAsNew fn
  • Call an activity for each workflow that waits for their result and clears items from pendingChildren on error or success

Unfortunately, workflows (at least in TS SDK) don't allow to wait for workflows that they didn't directly spawn. We can use getExternalWorkflowHandle, but it doesn't really expose much info/functionalyity (like wait for result or the status). Thus, we need to use activities.

bkniffler avatar Aug 17 '22 08:08 bkniffler

(if there is better strategies @tsurdilo, would love some feedback)

bkniffler avatar Aug 17 '22 08:08 bkniffler

Is #373 related(a valid preparation) to this issue?

picpromusic avatar Jan 22 '24 07:01 picpromusic