Skip to content

test: stabilize multi-grain cancellation - #10525

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-fix-task-cancellation-timeout
Aug 12, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-fix-task-cancellation-timeout

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

MultipleGrainsTaskCancellation can complete caller-side cancellation before one or more delayed requests begin executing. The test then waits for grain-side cancellation evidence which can never exist, producing the five-minute timeout seen on macOS.

Use the start-notification barrier added by #10461 for each delayed grain call before cancelling the shared token. Assigning each grain a distinct evidence ID lets the test prove that all five calls started and observed cancellation, while the zero-delay cases retain pre-start cancellation coverage.

Fixes #10439
Fixes #10440

Microsoft Reviewers: Open in CodeFlow

Wait for every delayed grain call to start before cancelling the shared token so grain-side cancellation evidence cannot be skipped.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 12, 2026 01:29

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

Stabilizes the MultipleGrainsTaskCancellation BVT by ensuring delayed interleaving calls have actually started executing on the grain before the shared cancellation token is triggered, preventing “wait for evidence which can never exist” timeouts (notably on macOS).

Changes:

  • Introduces per-grain callId values to disambiguate cancellation evidence across multiple grains.
  • Uses the start-notification barrier (LongWaitInterleavingWithStartNotification + observer) for delayed cases before scheduling cancellation.
  • Preserves the zero-delay path to continue exercising caller-side pre-start cancellation behavior.
Show a summary per file
File Description
test/Orleans.Runtime.Tests/CancellationTests/CancellationTokenTests.cs Updates the multi-grain cancellation test to wait for grain-side start notifications and to track cancellation evidence per grain call.

Review details

Tip

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

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

Await the independent grain cancellation evidence checks concurrently so a regression remains bounded by one timeout.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 13b77a0c-9317-4fdc-b06c-cef2ea19fd63
Copilot AI review requested due to automatic review settings August 12, 2026 01: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

Suppressed comments (1)

test/Orleans.Runtime.Tests/CancellationTests/CancellationTokenTests.cs:114

  • observer/observerReference are created and the object reference is registered even when delay == 0, but in that branch the reference is never used (the call path uses LongWaitInterleaving rather than the ...WithStartNotification overload). This adds unnecessary runtime work and can slightly perturb the zero-delay (pre-start cancellation) scenario. Consider creating/deleting the observer reference only when delay > 0.
        var callIds = grains.Select(_ => Guid.NewGuid()).ToArray();
        var observer = new LongRunningTaskObserver();
        var observerReference = fixture.GrainFactory.CreateObjectReference<ILongRunningTaskObserver>(observer);
        try
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@ReubenBond
ReubenBond merged commit fd9ab20 into dotnet:main Aug 12, 2026
136 of 138 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-task-cancellation-timeout branch August 12, 2026 03:28
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 11, 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.

Flaky test: MultipleGrainsTaskCancellation times out on macOS Flaky test: MultipleGrainsTaskCancellation times out after five minutes

2 participants