Skip to content

Fix lost-wakeup race in WorkScheduler serial task wait#10071

Merged
michaelstaib merged 2 commits into
mainfrom
mst/fix-scheduler
Jul 8, 2026
Merged

Fix lost-wakeup race in WorkScheduler serial task wait#10071
michaelstaib merged 2 commits into
mainfrom
mst/fix-scheduler

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Jul 8, 2026

Copy link
Copy Markdown
Member

Fixes #10051

Copilot AI review requested due to automatic review settings July 8, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a potential lost-wakeup race in the execution WorkScheduler when it waits for completion of a serial task (e.g., a mutation root field), and adds a regression test that stresses the specific concurrency window that previously could hang requests indefinitely.

Changes:

  • Make the “completed check” and _signal.Reset() occur within the same _sync lock region while waiting for a serial task, preventing a lost wakeup.
  • Refactor dispatch/completion logic into a locked TryDispatchOrCompleteUnsafe(...) helper to safely reuse logic from the wait path.
  • Add an integration stress test that runs many concurrent mutation executions with an async child resolver that yields to exercise the race window.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/MutationTests.cs Adds a high-concurrency regression test to detect hangs/timeouts caused by lost-wakeup behavior while awaiting serial mutation tasks.
src/HotChocolate/Core/src/Types/Execution/Processing/WorkScheduler.Execute.cs Fixes the lost-wakeup window by performing completion visibility check + signal reset under the same lock; refactors dispatch/completion logic for safe reuse.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelstaib michaelstaib merged commit e0d9dbf into main Jul 8, 2026
143 of 145 checks passed
@michaelstaib michaelstaib deleted the mst/fix-scheduler branch July 8, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lost-wakeup race in WorkScheduler.WaitForTask hangs requests forever (uncancellable, leaks a concurrency slot)

2 participants