Skip to content

Fix handling of immediate child workflow cancellation #276

@mfateev

Description

@mfateev

Currently when a single decision batch contains StartChildWorkflowExecution and RequestCancelExternalWorkflowExecution the cancellation fails and the child is started.
The expected behaviour is that the child is immediately cancelled ideally by writing the following events into the history:

  1. RequestCancelExternalWorkflowExecutionInitiated
  2. ExternalWorkflowExecutionCancelRequested
  3. ChildWorkflowExecutionCanceled

Here is an example history which shows the current broken behaviour:

   1  2020-04-05T16:34:53-07:00  EventTypeWorkflowExecutionStarted                         {WorkflowType:{Name:TestWorkflow_execute}, ParentInitiatedEventId:0,
                                                                                           TaskList:{Name:WorkflowTest-testChildWorkflowCancellation-49a80f10-fb1d-49c6-a9f1-282b2e31f460,
                                                                                           Kind:TaskListKindNormal}, Input:["WAIT_CANCELLATION_REQUESTED"],
                                                                                           ExecutionStartToCloseTimeoutSeconds:30, TaskStartToCloseTimeoutSeconds:5,
                                                                                           Initiator:ContinueAsNewInitiatorDecider, ContinuedFailureDetails:[], LastCompletionResult:[],
                                                                                           OriginalExecutionRunId:f2bc6299-a8b3-4996-9c0c-f4414f1a79bd, Identity:unknown-mac,
                                                                                           FirstExecutionRunId:f2bc6299-a8b3-4996-9c0c-f4414f1a79bd, Attempt:0, ExpirationTimestamp:0,
                                                                                           FirstDecisionTaskBackoffSeconds:0}
   2  2020-04-05T16:34:53-07:00  EventTypeDecisionTaskScheduled                            {TaskList:{Name:WorkflowTest-testChildWorkflowCancellation-49a80f10-fb1d-49c6-a9f1-282b2e31f460,
                                                                                           Kind:TaskListKindNormal}, StartToCloseTimeoutSeconds:5, Attempt:0}
   3  2020-04-05T16:34:53-07:00  EventTypeWorkflowExecutionCancelRequested                 {ExternalInitiatedEventId:0,
                                                                                           Identity:unknown-mac}
   4  2020-04-05T16:34:53-07:00  EventTypeDecisionTaskStarted                              {ScheduledEventId:2, Identity:unknown-mac,
                                                                                           RequestId:15e68a7d-672f-4e20-937c-3f3b3c646734}
   5  2020-04-05T16:34:53-07:00  EventTypeDecisionTaskCompleted                            {ExecutionContext:[],
                                                                                           ScheduledEventId:2,
                                                                                           StartedEventId:4,
                                                                                           Identity:unknown-mac}
   6  2020-04-05T16:34:53-07:00  EventTypeStartChildWorkflowExecutionInitiated             {WorkflowId:68563d49-3289-3c7a-9a39-e0e0d21d39bf,
                                                                                           WorkflowType:{Name:TestChildWorkflow_execute},
                                                                                           TaskList:{Name:WorkflowTest-testChildWorkflowCancellation-49a80f10-fb1d-49c6-a9f1-282b2e31f460,
                                                                                           Kind:TaskListKindNormal}, Input:[], ExecutionStartToCloseTimeoutSeconds:30,
                                                                                           TaskStartToCloseTimeoutSeconds:10, ParentClosePolicy:ParentClosePolicyAbandon,
                                                                                           Control:[], DecisionTaskCompletedEventId:5,
                                                                                           WorkflowIdReusePolicy:WorkflowIdReusePolicyAllowDuplicateFailedOnly}
   7  2020-04-05T16:34:53-07:00  EventTypeRequestCancelExternalWorkflowExecutionInitiated  {DecisionTaskCompletedEventId:5,
                                                                                           WorkflowExecution:{WorkflowId:68563d49-3289-3c7a-9a39-e0e0d21d39bf},
                                                                                           Control:[], ChildWorkflowOnly:true}
   8  2020-04-05T16:34:53-07:00  EventTypeRequestCancelExternalWorkflowExecutionFailed     {Cause:CancelExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution,
                                                                                           DecisionTaskCompletedEventId:-23, Namespace:UnitTest,
                                                                                           WorkflowExecution:{WorkflowId:68563d49-3289-3c7a-9a39-e0e0d21d39bf}, InitiatedEventId:7,
                                                                                           Control:[]}
   9  2020-04-05T16:34:53-07:00  EventTypeDecisionTaskScheduled                            {TaskList:{Name:unknown-mac:83e37a46-43b3-40e0-bbc0-a40f27208f84,
                                                                                           Kind:TaskListKindNormal}, StartToCloseTimeoutSeconds:5,
                                                                                           Attempt:0}
  10  2020-04-05T16:34:53-07:00  EventTypeChildWorkflowExecutionStarted                    {InitiatedEventId:6,
                                                                                           WorkflowExecution:{WorkflowId:68563d49-3289-3c7a-9a39-e0e0d21d39bf,
                                                                                           RunId:c4b71487-52e5-4984-a47d-105fa4478979},
                                                                                           WorkflowType:{Name:TestChildWorkflow_execute}}
  11  2020-04-05T16:34:53-07:00  EventTypeDecisionTaskStarted                              {ScheduledEventId:9,
                                                                                           Identity:83e37a46-43b3-40e0-bbc0-a40f27208f84,
                                                                                           RequestId:995457b0-b937-4333-b5c1-2b6083bee769}
  12  2020-04-05T16:34:53-07:00  EventTypeDecisionTaskCompleted                            {ExecutionContext:[],
                                                                                           ScheduledEventId:9,
                                                                                           StartedEventId:11,
                                                                                           Identity:unknown-mac}
  13  2020-04-05T16:35:23-07:00  EventTypeWorkflowExecutionTimedOut                        {TimeoutType:TimeoutTypeStartToClose}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions