-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Orchestrations are forced to wait for non-awaited tasks (forced fan-in) #2971
Comments
This is expected behavior. An orchestration never transitions into a completed state until all outstanding tasks are either completed or cancelled (cancellation currently only applies to timers). If you want true fire-and-forget, you'll need to start the background task from an activity function. In your case, change |
I suspect there is intention and effort to do that. It should be quite simple for the DF engine to see that function terminated without ContinueAsNew and move on. Instead engine refrains from signaling orchestration completion and starts waiting for sub orchestrations. This behavior is not consistent with async paradigm mimicked otherwise in the framework. I am wondering, what is cause and purpose of this? |
This behavior has been in place for the Durable Task Framework since before I became a maintainer, and I've been reluctant to change it since I'm not positive that I know what the implications would be. That said, we're adjusting this behavior in some of the newer SDKs, like Java, and we may end up doing the same with the .NET Isolated SDK after we remove its internal dependency on the Durable Task Framework (something we are planning to do as it's creating a lot of unnecessary complexity for us). |
This behavior is different from async/await pattern tradition, it is artificial and limiting. I would say even the first argument by itself should be enough to change the behavior. As an half-way option, a TaskOptions parameter for sub orchestrations could be a compromise, similar to WithInstanceId. |
Description
If orchestration A starts awaits sub-orchestration B which in turn starts asynchronous operation C (without await fire-and-forget style), await for sub orchestration B returns no earlier than operation C finishes. This makes it impossible to start independent fire-and forget orchestrations
Example:
"We re done" will not be printed until after 1 minute even though Orchestraion B is not blocked by Operation C nominally.
Expected behavior
"We re done" in the example should be printed immediately after Orchestration B finished executing body.
Actual behavior
Please see example.
Relevant source code snippets
Known workarounds
A workaround is to move scheduling of fire-and-forget task into an activity to be scheduled as independent orchestration.
App Details
Screenshots
Note the time of when "FireAndForgetFunctionsNonAwaiter fully completed" is printed.
For detailed output, run func with --verbose flag.
[2024-11-22T01:03:16.297Z] Host lock lease acquired by instance ID '0000000000000000000000000C75A72E'.
[2024-11-22T01:03:17.097Z] Executing 'Functions.FireAndForgetFunctions_HttpStart' (Reason='This function was programmatically called via the host APIs.', Id=a9c0a9a6-ecf1-498d-b907-6e32896208d3)
[2024-11-22T01:03:17.533Z] Scheduling new FireAndForgetFunctions orchestration with instance ID '600944a2b1d64ac2b2efabf3966d5b6b' and 0 bytes of input data.
[2024-11-22T01:03:17.720Z] Started orchestration with ID = '600944a2b1d64ac2b2efabf3966d5b6b'.
[2024-11-22T01:03:17.807Z] Executed 'Functions.FireAndForgetFunctions_HttpStart' (Succeeded, Id=a9c0a9a6-ecf1-498d-b907-6e32896208d3, Duration=734ms)
[2024-11-22T01:03:17.819Z] Executing 'Functions.FireAndForgetFunctions' (Reason='(null)', Id=629d082d-6dc5-49f1-a999-a5448291acec)
[2024-11-22T01:03:17.941Z] Saying hello.
[2024-11-22T01:03:17.981Z] Executed 'Functions.FireAndForgetFunctions' (Succeeded, Id=629d082d-6dc5-49f1-a999-a5448291acec, Duration=178ms)
[2024-11-22T01:03:18.043Z] Executing 'Functions.FireAndForgetFunctionsNonAwaiter' (Reason='(null)', Id=b63e060c-1518-4b1f-86b9-c1fbd47b1814)
[2024-11-22T01:03:18.067Z] NonAwaiter is done.
[2024-11-22T01:03:18.074Z] Executed 'Functions.FireAndForgetFunctionsNonAwaiter' (Succeeded, Id=b63e060c-1518-4b1f-86b9-c1fbd47b1814, Duration=33ms)
[2024-11-22T01:03:32.391Z] Executing 'Functions.FireAndForgetFunctionsNonAwaiter' (Reason='(null)', Id=657d5cca-e8de-48f9-a51b-7f56021ab6de)
[2024-11-22T01:03:32.413Z] Executed 'Functions.FireAndForgetFunctionsNonAwaiter' (Succeeded, Id=657d5cca-e8de-48f9-a51b-7f56021ab6de, Duration=22ms)
[2024-11-22T01:03:32.479Z] Executing 'Functions.FireAndForgetFunctions' (Reason='(null)', Id=9fb57156-46c2-45d9-a9b3-1074a7b0d5b2)
[2024-11-22T01:03:32.495Z] FireAndForgetFunctionsNonAwaiter fully completed.
[2024-11-22T01:03:32.503Z] Executed 'Functions.FireAndForgetFunctions' (Succeeded, Id=9fb57156-46c2-45d9-a9b3-1074a7b0d5b2, Duration=26ms)
If deployed to Azure
The text was updated successfully, but these errors were encountered: