-
Notifications
You must be signed in to change notification settings - Fork 3
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
Remove redundant and error-prone call to .Reset()
in our AutoResetEvents
#68
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
davidmrdavid
changed the title
Ensure active thread's AutoReset event is reset before yielding to completement thread
Remove redundant and error-prone call to Sep 5, 2023
.Reset()
in our AutoResetEvents
michaelpeng36
previously approved these changes
Sep 7, 2023
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
…le-powershell-private into dajusto/patch-thread-yielding
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
michaelpeng36
approved these changes
Sep 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: #65