Repository navigation
fix(durable-jobs): drain scheduling and activation on shutdown - #11256
Conversation
There was a problem hiding this comment.
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
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.
Code coverage
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 |
There was a problem hiding this comment.
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
Open (1)
Resolved since last review (1)
There was a problem hiding this comment.
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


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.
CloseAsynccloses 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