Skip to content

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

Merged
ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:rb-fix-readonly-scheduling
Oct 16, 2026
Merged

ReubenBond merged 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

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 81.56% (109,809 / 134,632) 81.59% (109,822 / 134,600) -0.0290 pp
Branches 70.42% (31,194 / 44,294) 70.49% (31,209 / 44,272) -0.0689 pp

Report-only conclusion: regressed.

The current-main baseline is commit e69d956b23 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

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

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

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

Copilot AI review requested due to automatic review settings September 10, 2026 15:27
@ReubenBond
ReubenBond force-pushed the rb-fix-readonly-scheduling branch from d05949a to a86b583 Compare September 10, 2026 15: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.

Copilot review overview

🔵 Needs a closer look

The changes alter core runtime scheduling/admission behavior in ActivationData, which is correctness-critical and warrants final human validation despite strong added test coverage.

Review tier: Lite
Findings: None

Copilot AI review requested due to automatic review settings September 10, 2026 19:45
@ReubenBond
ReubenBond force-pushed the rb-fix-readonly-scheduling branch from a86b583 to 5d4cb45 Compare September 10, 2026 19:45
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 16, 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.

ReadOnly requests can lose write exclusion when the first reader completes

2 participants