Skip to content

fix(durable-jobs): drain scheduling and activation on shutdown - #11256

Merged
ReubenBond merged 7 commits into
dotnet:mainfrom
ReubenBond:rb-fix-durable-jobs-drain-shutdown
Sep 15, 2026
Merged

ReubenBond merged 7 commits into
dotnet:mainfrom
ReubenBond:rb-fix-durable-jobs-drain-shutdown

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Problem

Scheduling, cancellation requests, and shard activation can race with shutdown. In-flight operations need to finish before shard disposal, and inactive shards need to release durable ownership so another silo can claim their jobs.

Solution

Use a shared atomic admission gate with scoped tokens for scheduling, cancellation requests, and activation. CloseAsync closes admission; shutdown signals request cancellation and drains admitted operations before snapshotting shard execution tasks and canceling execution. Activation publishes its actual task before releasing admission. Successful writes retain their results, and late successful creations remain owned until cleanup.

After execution and assignment work finishes, unregister inactive cached shards using the lifecycle shutdown token, then dispose them. The journaled provider releases populated shards for reassignment and deletes empty shards. Cleanup logs unregistration failures and continues releasing local resources.

Rationale

Extract the lifecycle changes independently from #11210 while retaining the existing discovery policy. Scoped atomic admission preserves concurrent scheduling and gives shutdown explicit ownership of each admitted operation and shard resource.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 15, 2026 05:46

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

🟡 Changes recommended

Unresolved critical and moderate shutdown lifecycle issues block approval.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This pull request hardens Durable Jobs shutdown handling across scheduling, shard activation, cancellation, and cleanup.

Changes:

  • Adds admission gates and drains operations during shutdown.
  • Tracks activation tasks and manages shard ownership.
  • Adds concurrency tests and lifecycle documentation.
File Summary
test/​Orleans.Core.Tests/​DurableJobs/​LocalDurableJobManagerTests.cs Adds scheduling and shutdown race coverage.
src/​Orleans.DurableJobs/​README.md Documents shutdown lifecycle behavior.
src/​Orleans.DurableJobs/​LocalDurableJobManager.cs Implements lifecycle coordination and cleanup; unresolved shutdown reentrancy and cancellation-disposal issues remain.

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

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request
Lines 81.75% (110,464 / 135,131)
Branches 70.64% (31,395 / 44,444)

Report-only conclusion: current-main baseline stale.

The newest successful coverage run tested 3e457bc, not current main 8905026.

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 September 15, 2026 18:15

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

🟡 Changes recommended

Cancellation operations can race with shard disposal during shutdown, causing failures.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Copilot AI review requested due to automatic review settings September 15, 2026 18:42

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

🟡 Changes recommended

Unresolved critical and moderate lifecycle issues remain in LocalDurableJobManager.cs.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite
Findings: 2 High severity

Open (2)

Copilot AI review requested due to automatic review settings September 15, 2026 19:02

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

🟡 Changes recommended

The admission race and shutdown cleanup issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
Resolved since last review (2)

Comment thread src/Orleans.Core/Async/AdmissionGate.cs Resolved
Copilot AI review requested due to automatic review settings September 15, 2026 19:19

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

Concurrent shutdown draining and shard ownership cleanup warrant final human review.

Review tier: Lite
Findings: None

Resolved since last review (2)

@ReubenBond
ReubenBond merged commit e97d385 into dotnet:main Sep 15, 2026
67 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-durable-jobs-drain-shutdown branch September 15, 2026 19:26
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 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.

2 participants