temporalio / sdk-core

Core Temporal SDK that can be used as a base for language specific Temporal SDKs
MIT License
278 stars 77 forks source link

[Bug] A child workflow with CancellationType.Abandon completing after cancelling the parent leads to an invalid state #568

Closed PenguinToast closed 1 year ago

PenguinToast commented 1 year ago

What are you really trying to do?

See #523

Describe the bug

A pretty similar case as #523 -- if a child workflow finishes after the parent workflow has already received a cancellation request, then the workflow ends up in stuck state with the error:

Fatal(\"ChildWorkflowMachine in state Cancelled says the transition is invalid during event EventInfo { event_id: 57, event_type: ChildWorkflowExecutionCompleted }\")

It seems like we should either make all transitions for the child workflow state machine out of Cancelled valid (for child workflow completion, cancellation, failure, or termination), or not put the child workflow state machine in the state Cancelled pre-emptively if the CancellationType is Abandon

Environment/Versions

Running on Temporal version 1.18 with Typescript SDK 1.7.0

PenguinToast commented 1 year ago

@Sushisource happy to help implement a fix here -- just need direction on what you think is the right way to fix this!

Sushisource commented 1 year ago

@PenguinToast Probably the right approach here is either a separate CancelledAbandoned state, or to just look at the cancel type and be OK with swallowing a transition like this while in Cancelled if we had the abandoned type.

I should be able to fix this fairly soon (next week sometime), but if you want to try a fix, by all means go for it :)