Azure / azure-functions-durable-powershell

PowerShell SDK for writing Durable Functions apps
MIT License
7 stars 3 forks source link

Remove redundant and error-prone call to `.Reset()` in our AutoResetEvents #68

Closed davidmrdavid closed 12 months ago

davidmrdavid commented 1 year ago

The standalone DF PS SDK manages two threads: (1) the user-code thread and (2) the DTFx thread. Only one thread can be active at a time, and yield control to any given thread using AutoReset events.

In today's implementation, in order to yield control to the other thread, we perform the following steps, in order: (A) We wake the other thread (B) We manually reset this thread's AutoReset event (there's technically no reason to do this, the autoresetevent should automatically reset after its corresponding thread wakes up) (C) We block this thread until the AutoReset event is signaled.

After step (A) but before step (B), it's possible for the complement thread to signal the yielding thread's autoreset event. If this occurs, then in step (B) we will discard the complement thread's signal because we reset the AutoReset event. At that point, the orchestrator gets stuck.

In this PR, we remove the redundant call to the .Reset() API to avoid this race condition. Now we rely solely on the automatic reset of this data structure.

This should fix: https://github.com/Azure/azure-functions-durable-powershell/issues/65

davidmrdavid commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
davidmrdavid commented 12 months ago

/azp run

azure-pipelines[bot] commented 12 months ago
Azure Pipelines successfully started running 1 pipeline(s).
davidmrdavid commented 12 months ago

/azp run

azure-pipelines[bot] commented 12 months ago
Azure Pipelines successfully started running 1 pipeline(s).
davidmrdavid commented 12 months ago

/azp run

azure-pipelines[bot] commented 12 months ago
Azure Pipelines successfully started running 1 pipeline(s).
davidmrdavid commented 12 months ago

/azp run

azure-pipelines[bot] commented 12 months ago
Azure Pipelines successfully started running 1 pipeline(s).
davidmrdavid commented 12 months ago

/azp run

azure-pipelines[bot] commented 12 months ago
Azure Pipelines successfully started running 1 pipeline(s).