How does cancel work with mutex across different workflows?

I current have the current flow:

  • Parent workflow 1
    - child workflow [ have a mutex to lock the resources, and has a defer will trigger the unlock ]
    - child workflow [ this workflow is blocked till mutex is unlocked]
  • Parent workflow 2
    - similar setup with the child workflow as above where the mutex if locked in workflow 1 would block the child workflow here

There two possible scenarios:

  1. Send a cancel on workflow 1. This should cancel the child workflows and unlock the mutex.
  2. Send a cancel to workflow 2. In this case, the mutex is still being blocked by workflow 1. Will the cancel wait till the mutex is unlocked?

I’m seeing this comment as well, leaving me to believe that it’s being held back. Wanted to get a better understanding why a cancel would be queued up vs. being triggered right away or is there edge cases that I need to factor in.

Cancel Request Sent

The request to cancel this Workflow Execution has been sent. If the Workflow uses the cancellation API, it'll cancel at the next available opportunity.

What do you mean by “mutex” in this case?

Pretty much similar to the mutex in this example.

I see. I don’t understand the premise of your question. You code your workflow logic, so you can support either scenario you listed or any other scenario that makes sense for your use case.

If you have a problem coding a specific scenario, we can help. But we need more details about the issue you are facing.

Let me see if i can reproduce it with a sample example. I think it might be something in my code that is causing this issue.