Skip to content

fix: deactivate existing grains without activating them - #11483

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
KSemenenko:codex/deactivate-existing-grain
Oct 21, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
KSemenenko:codex/deactivate-existing-grain

Conversation

@KSemenenko

@KSemenenko KSemenenko commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Management callers cannot safely deactivate an existing grain by resolving its activation address and invoking the management extension: a stale address or a concurrent deactivation can turn the extension RPC into a new activation, which reads persisted state. This prevents lifecycle operations from safely handling unreadable state.

Add IManagementGrain.DeactivateGrain(GrainId, CancellationToken). The management grain asks each active silo's system target to inspect its activation registry and deactivate the matching context directly. Missing contexts are a no-op; stateless workers are included. Completion waits for the matching deactivation callbacks. Once deactivation is requested, cancellation stops waiting without cancelling teardown. Ordinary later calls can still activate the grain.

The change includes the generated wire manifest and public API, plus package-scoped CP0006 suppressions for the new interface member. Four focused lifecycle regressions pass on both net8.0 and net10.0. The normal Release pack succeeds; baseline APICompat also reports reference-resolution warnings for Microsoft.AspNetCore.Connections.Abstractions and Microsoft.Extensions.Features. Automated PR coverage is not available yet.

Fixes #11482.

Microsoft Reviewers: Open in CodeFlow

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 83.57% (119,042 / 142,447) 83.58% (119,037 / 142,429) -0.0071 pp
Branches 73.23% (35,448 / 48,404) 73.21% (35,432 / 48,398) +0.0240 pp

Report-only conclusion: mixed.

The current-main baseline is commit fbe240c34e and uses the same reviewed coverage matrix.

Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.

The comparison remains report-only while normal line and branch variance is calibrated.

Coverage details

Comment thread src/Orleans.Runtime/Silo/SiloControl.cs Resolved
@KSemenenko
KSemenenko force-pushed the codex/deactivate-existing-grain branch from 815fea5 to 638d8f8 Compare October 13, 2026 22:01
@ReubenBond
ReubenBond force-pushed the codex/deactivate-existing-grain branch from 638d8f8 to 863df35 Compare October 19, 2026 21:07

@ReubenBond ReubenBond left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the management-to-silo boundary, activation-directory lookup, activation/deactivation lifecycle, stateless-worker teardown, cancellation ownership, and generated API/contract changes. No blocking findings. The silo-side operation uses the existing context's lifecycle and waits for teardown; it avoids the stale-address grain-RPC activation race. The application-requested deactivation reason is correct. All four focused ManagementDeactivationTests passed locally on net8.0 and net10.0, including three additional complete-class repeats on each framework (32 passing executions total). CI is green for head 863df35. The coverage report shows 83.57% overall line coverage; affected-code coverage is not separately reported. Ready for the preview release.

@ReubenBond
ReubenBond merged commit 3a33a53 into dotnet:main Oct 21, 2026
94 checks passed
ReubenBond pushed a commit to ReubenBond/orleans that referenced this pull request Oct 22, 2026
(cherry picked from commit 3a33a53)

Retain only the explicitly approved management-member CP0006 suppression for each target framework, regenerated against 10.4.0, and document the all-active-silos rollout gate.

Upstream-PR: dotnet#11483
Upstream-Commit: 3a33a53
ReubenBond pushed a commit to ReubenBond/orleans that referenced this pull request Oct 22, 2026
(cherry picked from commit 3a33a53)

Retain only the explicitly approved management-member CP0006 suppression for each target framework, regenerated against 10.4.0, and document the all-active-silos rollout gate.

Upstream-PR: dotnet#11483
Upstream-Commit: 3a33a53
ReubenBond pushed a commit that referenced this pull request Oct 23, 2026
(cherry picked from commit 3a33a53)

Retain only the explicitly approved management-member CP0006 suppression for each target framework, regenerated against 10.4.0, and document the all-active-silos rollout gate.

Upstream-PR: #11483
Upstream-Commit: 3a33a53
@KSemenenko
KSemenenko deleted the codex/deactivate-existing-grain branch October 29, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Management deactivation can activate an inactive grain

2 participants