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.
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