Skip to content

Stop PlacementService workers during shutdown#9993

Merged
ReubenBond merged 1 commit into
mainfrom
reubenbond/issue-9827-placement-service-disposal
Apr 28, 2026
Merged

Stop PlacementService workers during shutdown#9993
ReubenBond merged 1 commit into
mainfrom
reubenbond/issue-9827-placement-service-disposal

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Apr 7, 2026

Copy link
Copy Markdown
Member

Fixes #9827.

Why

PlacementService starts background worker loops but did not participate in the silo lifecycle. During shutdown those workers could continue into placement resolution and touch keyed services after the silo was already stopping, which could surface the logged ObjectDisposedException from IServiceProvider disposal.

What changed

  • register PlacementService as an ISiloLifecycle participant and stop it at ServiceLifecycleStage.RuntimeInitialize + 1
  • signal and await the placement workers so they do not outlive shutdown
  • reject new queued placement work once shutdown begins, while keeping the stop checks only at the points which actually protect against post-stop service resolution
  • add focused regression tests covering worker shutdown and post-stop placement rejection

Notes

This fixes the lifetime mismatch directly instead of catching and suppressing ObjectDisposedException in the worker loop.

Validation

  • dotnet build Orleans.slnx -nologo
  • dotnet test test\\Orleans.Core.Tests\\Orleans.Core.Tests.csproj -nologo --filter "FullyQualifiedName~PlacementServiceTests"
Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond force-pushed the reubenbond/issue-9827-placement-service-disposal branch from b009dcc to f4b7289 Compare April 10, 2026 17:45
@ReubenBond ReubenBond force-pushed the reubenbond/issue-9827-placement-service-disposal branch from f4b7289 to 0eea53b Compare April 24, 2026 00:34
@ReubenBond ReubenBond added this pull request to the merge queue Apr 24, 2026
@ReubenBond ReubenBond removed this pull request from the merge queue due to a manual request Apr 24, 2026
@ReubenBond ReubenBond force-pushed the reubenbond/issue-9827-placement-service-disposal branch from 1de0ef3 to 523bdcd Compare April 24, 2026 17:21
@ReubenBond ReubenBond enabled auto-merge April 24, 2026 17:21
@ReubenBond ReubenBond added this pull request to the merge queue Apr 24, 2026
@ReubenBond ReubenBond removed this pull request from the merge queue due to a manual request Apr 24, 2026
@ReubenBond ReubenBond force-pushed the reubenbond/issue-9827-placement-service-disposal branch 3 times, most recently from 4fd88c2 to 32d25d9 Compare April 27, 2026 23:28
Register PlacementService with the silo lifecycle so placement workers are signaled and awaited during shutdown. Reject new placement work once shutdown begins and expose diagnostics for focused regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond ReubenBond force-pushed the reubenbond/issue-9827-placement-service-disposal branch from 32d25d9 to 36b29f9 Compare April 28, 2026 03:20
@ReubenBond ReubenBond added this pull request to the merge queue Apr 28, 2026
Merged via the queue into main with commit 06cb865 Apr 28, 2026
62 checks passed
@ReubenBond ReubenBond deleted the reubenbond/issue-9827-placement-service-disposal branch April 28, 2026 04:26
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PlacementService disposal?

1 participant