Repository navigation
fix(runtime): fault outstanding callbacks when a host shuts down - #10275
Merged
ReubenBond merged 1 commit intoJul 16, 2026
Merged
ReubenBond merged 1 commit into
ReubenBond merged 1 commit into
Conversation
When a silo or client shuts down it can no longer receive responses, so any grain-call requests still outstanding will never complete and the awaiting caller hangs forever. This is especially damaging on an ungraceful silo shutdown, where an activation awaiting an outbound response cannot be deactivated, blocking grain context disposal and, in turn, host disposal. Fault all outstanding callbacks during shutdown so in-flight calls observe a terminal SiloUnavailableException instead of hanging: - CallbackData.OnHostShutdown completes the callback with a terminal exception, guarding against double-completion with the same interlocked compare-exchange used by OnTimeout and OnTargetSiloFail. - InsideRuntimeClient breaks its outstanding callbacks at the RuntimeInitialize lifecycle stop stage, which runs last (after messaging has stopped), so faulting is always safe; graceful shutdowns have already drained their grains, so it is a no-op there. - OutsideRuntimeClient breaks its outstanding callbacks in StopAsync once messaging has stopped, mirroring the silo path. Adds a deterministic client regression test that hangs without the fix and passes with it. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 9906ce19-ea34-481d-8b0c-ca71a3223a05
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This was referenced Jul 22, 2026
This was referenced Jul 29, 2026
This was referenced Jul 29, 2026
Merged
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
When an Orleans host (silo or client) shuts down, it can no longer receive responses to grain calls. Any requests still outstanding at that point never complete, so the awaiting caller hangs forever.
This is especially damaging during an ungraceful silo shutdown. If an activation is awaiting an outbound response, it cannot be deactivated, which blocks disposal of its grain context and, in turn, blocks disposal of the host itself. This manifests as a hang during host/
ServiceProviderdisposal (observed while stopping in-process test clusters, and surfaced by the leak fix in #10272).Regular activations only cancel their pending operations during disposal, but a
[StatelessWorker]grain context awaitsworker.Deactivated, which cannot complete while the worker is blocked on an in-flight outbound call whose callback will never be signalled.Solution
Fault all outstanding grain-call callbacks during host shutdown so in-flight calls observe a terminal
SiloUnavailableExceptioninstead of hanging:CallbackData.OnHostShutdown()completes the callback with a terminal exception, guarding against double-completion with the same interlocked compare-exchange used byOnTimeout/OnTargetSiloFail.InsideRuntimeClientbreaks its outstanding callbacks at theRuntimeInitializelifecycle stop stage, which runs last (after messaging has stopped), so faulting is always safe. Graceful shutdowns have already drained their grains, so it is effectively a no-op there; only ungraceful shutdowns leave residual callbacks.OutsideRuntimeClientbreaks its outstanding callbacks inStopAsynconce messaging has stopped, mirroring the silo path so clients no longer hang on in-flight calls at shutdown.Includes a deterministic client regression test (
HostShutdownCallbackTests) that hangs without the fix and passes with it.This is the base change; the in-process test cluster disposal/leak fix (#10272) builds on top of it.
Microsoft Reviewers: Open in CodeFlow