fix(runtime): preserve ReadOnly scheduling isolation - #10809
Conversation
There was a problem hiding this comment.
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
ActivationDatarequest 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, andMayInterleave. - Clarify public and internal scheduling documentation and add remarks to
ReadOnlyAttributedescribing 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
Code coverage77.65% line coverage - 97,649 / 125,759 lines Coverage details
|
94e9e8d to
5897310
Compare
795dbf3 to
8c88391
Compare
|
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. |
8c88391 to
9c6d7b6
Compare
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 heterogeneousMayInterleavecohorts.Closes #10807.
Solution
_blockingRequestfocused on diagnostics and stuck-request tracking by pointing it at the request which actually prevents admission.AlwaysInterleave,Reentrant, and mixedMayInterleavesurvivors.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