Skip to content

fix(runtime): use private synchronization lock for ActivationData#10068

Draft
ReubenBond wants to merge 1 commit into
dotnet:mainfrom
ReubenBond:split/activationdata-locking
Draft

fix(runtime): use private synchronization lock for ActivationData#10068
ReubenBond wants to merge 1 commit into
dotnet:mainfrom
ReubenBond:split/activationdata-locking

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Apr 30, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a private synchronization lock to ActivationData and uses it instead of locking on the activation instance.
  • Routes external activation-locking call sites (ActivationCollector, activation migration acceptance, and incoming request monitoring) through the same synchronization lock.
  • Gives activation command cancellation/disposal its own private lock instead of locking on the command object.

Validation

  • git diff --check HEAD^ HEAD
  • conflict-marker scan
  • dotnet build src\Orleans.Runtime\Orleans.Runtime.csproj -m --no-restore -v:q
  • dotnet test test\Orleans.Core.Tests\Orleans.Core.Tests.csproj --filter FullyQualifiedName~ActivationCollectorTests (28 passed; existing xUnit serialization warnings only)

Notes

  • No collection ticket algorithm changes are included.
  • Review focus: activation collection versus deactivation races, lock ordering, and no deadlock regressions.
Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond changed the title Fix ActivationData locking semantics Use private synchronization lock for ActivationData Apr 30, 2026
@ReubenBond ReubenBond requested a review from Copilot April 30, 2026 04:36

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 updates Orleans Runtime activation synchronization by introducing a private lock object on ActivationData and routing external activation-locking call sites to use it, instead of locking on activation instances or command objects. This aims to reduce accidental lock coupling and make activation state synchronization more explicit and controllable across the runtime.

Changes:

  • Added a private synchronization lock to ActivationData and replaced lock(this) with lock(_lock) for mutable activation state.
  • Updated external call sites (ActivationCollector, activation migration acceptance, and incoming request workload monitoring) to lock using the activation synchronization lock.
  • Updated activation command cancellation/disposal synchronization to use a private lock object instead of locking on the command instance.
Show a summary per file
File Description
src/Orleans.Runtime/Catalog/IncomingRequestMonitor.cs Uses activation.SynchronizationLock when analyzing activation workload.
src/Orleans.Runtime/Catalog/ActivationMigrationManager.cs Uses activation.SynchronizationLock when polling activation state during migration acceptance.
src/Orleans.Runtime/Catalog/ActivationData.cs Introduces _lock, exposes SynchronizationLock, replaces internal lock(this) usage, and adds GetSynchronizationLock helper for collector call sites.
src/Orleans.Runtime/Catalog/ActivationCollector.cs Locks collectible contexts via ActivationData.GetSynchronizationLock(...) instead of locking on the context instance.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond ReubenBond force-pushed the split/activationdata-locking branch from ac3c1c8 to 25ab5d6 Compare April 30, 2026 15:33
@ReubenBond ReubenBond changed the title Use private synchronization lock for ActivationData fix(runtime): use private synchronization lock for ActivationData May 29, 2026
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.

2 participants