Fix race condition in WaitForInstanceAsync causing intermittent test failures#574
Merged
YunchuWang merged 3 commits intomainfrom Dec 17, 2025
Merged
Conversation
…End test to fail The original code had a TOCTOU race condition where a completion notification could be missed if the orchestration completed between checking completion status and adding the waiter. The fix reorders the operations to add the waiter first, then check for completion. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate and fix failing testcase in DurableTaskGrpcClientIntegrationTests
Fix race condition in WaitForInstanceAsync causing intermittent test failures
Dec 17, 2025
Member
|
LGTM |
YunchuWang
approved these changes
Dec 17, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an intermittent race condition in WaitForInstanceAsync that was causing the RestartAsync_EndToEnd test to fail. The issue occurred when an orchestration completed between checking its status and registering a waiter, resulting in missed completion notifications and 30-second timeouts.
Key Changes:
- Reordered operations in
WaitForInstanceAsyncto register the waiter before checking completion status, eliminating the race condition window - Added clear comments explaining the race condition fix and the two-step registration-then-check pattern
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
|
@copilot update pr description to follow .github/PULL_REQUEST_TEMPLATE.md |
halspang
approved these changes
Dec 17, 2025
Copilot stopped work on behalf of
YunchuWang due to an error
December 17, 2025 23:42
This file contains hidden or 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
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.
RestartAsync_EndToEnd(restartWithNewInstanceId: True)was failing intermittently due to a TOCTOU race condition inWaitForInstanceAsync.Problem
The original code checked completion status before adding a waiter. If orchestration completed between these two steps, the completion notification was sent to no registered waiter, causing the caller to wait indefinitely (30s timeout).
Fix
Reorder operations to add waiter first, then check status:
This ensures we either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.