Repository navigation
feat(runtime): add activation keep-alive holds - #11506
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Final release can reinsert a disposed activation into the working set, and independent idle-reset regression coverage is missing.
2 open findings
What changed in this PR
Adds internal, counted activation keep-alive holds for background work, preparing the runtime for durable messaging.
Changes:
- Makes idle collection respect holds while allowing explicit and memory-pressure deactivation.
- Restarts idleness on final release using shared activity bookkeeping.
- Adds collection tests and supporting grain methods.
Automated coverage results were unavailable.
| File | Description |
|---|---|
| test/Orleans.Runtime.Internal.Tests/ActivationsLifeCycleTests/ActivationCollectorTests.cs | Tests collection with multiple holds. |
| test/Grains/TestInternalGrains/ActivationGCTestGrains.cs | Implements test hold operations. |
| test/Grains/TestInternalGrainInterfaces/ActivationGCTestGrainInterfaces.cs | Exposes test hold operations. |
| src/Orleans.Runtime/Catalog/ActivationData.cs | Implements holds and collection integration. |
| src/Orleans.Core/Runtime/IActivationKeepAlive.cs | Defines the internal hold contract. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: regressed. The current-main baseline is commit 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 |


Problem
Runtime components that perform background work on behalf of an activation — for example, the durable messaging pump servicing queued work and in-flight outbox deliveries — need to keep that activation from being idle-collected while the work is pending. Per-message keep-alive and
DelayDeactivationmodel neither "held while X is in flight" nor multiple independent holders.Solution
IActivationKeepAliveinterface (AcquireKeepAlive/ReleaseKeepAlive), implemented byActivationData.intfield on the lazily allocatedActivationDataExtra.TryDeactivateForCollectionwithrespectKeepAlive, and the working-setIsCandidateForRemovalcheck. Memory-pressure collection and explicit deactivation proceed regardless of holds.MarkActivehelper, whichOnCompletedRequestnow shares. A deactivating or disposed activation stays out of the working set.ActivationCollectorTestscoverage. One test checks that counted holds keep an activation alive and that it is collected after release. Another releases the final hold outside request processing after the original idle period expired, and checks that collection waits for a fresh idle period.Rationale
ActivationDatagains no new fields; only activations which take holds allocate the extras. The API is internal, so there is no public API surface change. This was split out of #11505 (RunRequestAsync), and its first consumer is the durable messaging pump in #11282.Microsoft Reviewers: Open in CodeFlow