Repository navigation
fix(streaming): refresh idle EventHub cursors to avoid QueueCacheMissException - #10266
Merged
ReubenBond merged 1 commit intoJul 15, 2026
Merged
Conversation
…Exception Orleans retains inactive stream cursors longer than the EventHub cache retains data and token metadata. When new data woke an inactive consumer, PersistentStreamPullingAgent called cursor.Refresh(startToken), but the EventHub cursor's Refresh was an empty no-op. The stale cursor then requested an evicted token and threw QueueCacheMissException. This adds real refresh support to the shared PooledQueueCache: an idle or unset cursor is repositioned to the supplied non-null sequence token (the first newly available event) without skipping it, while an active (Set) cursor mid-enumeration is left untouched. Refresh only ever moves a cursor forward, so a cursor already positioned at or ahead of the requested token is left in place rather than rewound. EventHubQueueCache and the EventHub cursor now delegate to it, and IEventHubQueueCache.Refresh is a default-implemented no-op so external cache implementations keep working. Regression coverage is added at the cache, EventHub adapter, and pulling-agent levels, including the idle -> purge -> new-event wake-up sequence. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 638ef335-61cb-4f6c-8261-c2f778b0f9a6
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a correctness issue in Orleans streaming where inactive EventHub stream cursors can outlive both cached messages and the cache’s token metadata, leading to QueueCacheMissException when an inactive subscription is reactivated. The fix adds concrete “refresh” behavior to PooledQueueCache and wires EventHub’s cursor/cache to use it, with targeted unit/integration tests.
Changes:
- Added
PooledQueueCache.Refresh(...)to reposition idle/unset cursors to a provided start token (no-op fornull, and never rewinds/doesn’t move active cursors). - Added
IEventHubQueueCache.Refresh(...)(default no-op) and delegatedEventHubQueueCache/cursor refresh behavior to the underlying pooled cache. - Added tests covering idle-cursor refresh after purge, active-cursor non-repositioning, and “no rewind” behavior, plus an EventHub delegation test.
Show a summary per file
| File | Description |
|---|---|
| test/Orleans.Streaming.Tests/StreamingTests/PersistentStreamPullingAgentTests.cs | Adds an integration-style test reproducing the idle → purge → new-event wake-up scenario using a purgeable pooled cache wrapper. |
| test/Orleans.Streaming.Tests/OrleansRuntime/Streams/PooledQueueCacheTests.cs | Adds cache-level unit tests validating refresh semantics (idle/unset reposition, active no-op, and forward-only behavior). |
| test/Extensions/Orleans.Streaming.EventHubs.Tests/CheckpointerTests/EventHubCheckpointerTests.cs | Adds a test ensuring EventHub cursor Refresh delegates to the EventHub cache. |
| src/Orleans.Streaming/Common/PooledCache/PooledQueueCache.cs | Implements Refresh for pooled-cache cursors with the intended safety rules (no-op for null, don’t move active cursors, don’t rewind). |
| src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/IEventHubQueueCache.cs | Adds Refresh as a default-implemented no-op extension point for binary/source compatibility. |
| src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubQueueCache.cs | Delegates Refresh to the underlying PooledQueueCache. |
| src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterReceiver.cs | Makes EventHub cursor Refresh call into the cache’s refresh implementation. |
| src/api/Orleans.Streaming/Orleans.Streaming.cs | Updates public API surface for PooledQueueCache.Refresh. |
| src/api/Azure/Orleans.Streaming.EventHubs/Orleans.Streaming.EventHubs.cs | Updates public API surface for IEventHubQueueCache.Refresh and EventHubQueueCache.Refresh. |
Copilot's findings
- Files reviewed: 9/9 changed files
- Comments generated: 0
ReubenBond
marked this pull request as ready for review
July 15, 2026 19:29
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This was referenced Jul 22, 2026
This was referenced Jul 29, 2026
This was referenced Jul 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Orleans retains inactive stream cursors longer than the EventHub cache retains data and token metadata. When new data wakes an inactive consumer,
PersistentStreamPullingAgent.StartInactiveCursorscallscursor.Refresh(startToken)— but EventHub'sCursor.Refreshwas an empty no-op. The stale cursor then requested an already-evicted token and threwQueueCacheMissException.Solution
Add real refresh support to the shared
PooledQueueCache:startToken(the first newly available event) without skipping it. The cursor is reset toUnsetbeforeSetCursorso it lands exactly at the token rather than being advanced past it by the idle-skip path.Set) cursor that is mid-enumeration is left untouched.SimpleQueueCache's conservatism.nulltoken is a no-op, preserving the previous behavior on the delivery hot path.EventHubQueueCacheand the EventHub cursor now delegate toPooledQueueCache.Refresh.IEventHubQueueCache.Refreshis added as a default-implemented no-op so external cache implementations of this documented extension point keep compiling.Tests
QueueCacheMissException; refresh does not reposition an active cursor; refresh does not rewind a cursor already holding a future token.Refreshdelegates to the underlying cache.Microsoft Reviewers: Open in CodeFlow