Skip to content

fix(runtime): preserve ReadOnly scheduling isolation - #10809

Open
ReubenBond wants to merge 3 commits into
dotnet:mainfrom
ReubenBond:rb-fix-readonly-scheduling
Open

fix(runtime): preserve ReadOnly scheduling isolation#10809
ReubenBond wants to merge 3 commits into
dotnet:mainfrom
ReubenBond:rb-fix-readonly-scheduling

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 24, 2026

Copy link
Copy Markdown
Member

Problem

When multiple [ReadOnly] requests were active, request admission relied on a single _blockingRequest. If that representative completed first, a writable request could start while another read-only request was still active. A single representative was also insufficient for heterogeneous MayInterleave cohorts.

Closes #10807.

Solution

  • Evaluate heterogeneous admissions against every active request so each pair must be compatible.
  • Preserve constant-time paths for ordinary and homogeneous read-only workloads using active-request counters.
  • Keep _blockingRequest focused on diagnostics and stuck-request tracking by pointing it at the request which actually prevents admission.
  • Add deterministic coverage for request flags, interface inheritance and redeclaration, overloads, generics, read/write ordering, both reader completion orders, AlwaysInterleave, Reentrant, and mixed MayInterleave survivors.
  • Clarify the public and conceptual scheduling contract, including interface-method attribute placement and policy overrides.

Rationale

Pairwise compatibility expresses the scheduling invariant directly and remains correct when active requests have different interleaving policies. Aggregate counters avoid scanning the common single-request and read-only batch paths.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings August 24, 2026 21:16

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 scheduling correctness issue in the Orleans runtime where writable requests could be admitted while a read-only request was still active (when multiple [ReadOnly] requests were running and the “representative” blocker completed first). It updates the activation admission logic to evaluate compatibility against all active requests while preserving fast paths for common cases, and adds targeted tests and documentation clarifications around the scheduling contract.

Changes:

  • Update ActivationData request admission to use active-request counters for common paths and pairwise compatibility checks against all running requests for heterogeneous interleaving scenarios.
  • Add a comprehensive internal test suite (plus test grains and interfaces) covering read-only flagging semantics and admission ordering across ReadOnly, AlwaysInterleave, Reentrant, and MayInterleave.
  • Clarify public and internal scheduling documentation and add remarks to ReadOnlyAttribute describing the intended contract and attribute placement.
Show a summary per file
File Description
test/Orleans.Runtime.Internal.Tests/ReadOnlyAttributeTests.cs Adds deterministic functional tests for read-only request flagging and admission ordering across multiple interleaving policies.
test/Grains/TestGrains/ReadOnlySchedulingGrain.cs Introduces test grains used to block/unblock operations and exercise scheduling/interleaving behavior.
test/Grains/TestGrainInterfaces/IReadOnlySchedulingGrain.cs Adds test grain interfaces with attribute combinations to validate effective request options and scheduling rules.
src/Orleans.Runtime/Catalog/ActivationData.cs Fixes request admission logic to preserve read-only isolation and handle heterogeneous interleaving cohorts correctly.
src/Orleans.Core.Abstractions/Concurrency/GrainAttributeConcurrency.cs Adds remarks clarifying the ReadOnlyAttribute scheduling contract and intended usage.
docs/site/src/content/docs/implementation/scheduler.md Updates internal scheduler documentation to reflect pairwise compatibility evaluation.
docs/site/src/content/docs/grains/request-scheduling.md Clarifies user-facing ReadOnly scheduling semantics and how it interacts with other interleaving policies.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/Orleans.Runtime/Catalog/ActivationData.cs Outdated
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Code coverage

77.65% line coverage - 97,649 / 125,759 lines

Coverage details

Copilot AI review requested due to automatic review settings August 24, 2026 23: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.

Review details

  • Files reviewed: 10/10 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread src/Orleans.Runtime/Catalog/RequestScheduler.cs Outdated
Comment thread src/Orleans.Runtime/Catalog/RequestScheduler.cs Outdated
Copilot AI review requested due to automatic review settings August 25, 2026 01:27
@ReubenBond
ReubenBond force-pushed the rb-fix-readonly-scheduling branch from 94e9e8d to 5897310 Compare August 25, 2026 01:27

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.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 25, 2026 09:13

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.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@ReubenBond

Copy link
Copy Markdown
Member Author

Documentation run 32833379243 is failing deterministically because six NuGet-link allowlist entries now return 200 and are reported as stale. Current main includes #10818, which removes those recovered allowlist entries. I am rebasing this branch onto current main and will push the refreshed branch after the solution build succeeds.

Copilot AI review requested due to automatic review settings August 26, 2026 14:25
@ReubenBond
ReubenBond force-pushed the rb-fix-readonly-scheduling branch from 8c88391 to 9c6d7b6 Compare August 26, 2026 14:25

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.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread test/Orleans.Runtime.Internal.Tests/ReadOnlyAttributeTests.cs Outdated
Copilot AI review requested due to automatic review settings August 26, 2026 14:48

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.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

ReadOnly requests can lose write exclusion when the first reader completes

2 participants