Skip to content

fix(streaming): recover cache misses from oldest data - #9711

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
BMagerMT:recover-from-queue-cache-miss-with-oldeset-data
Sep 4, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
BMagerMT:recover-from-queue-cache-miss-with-oldeset-data

Conversation

@BMagerMT

@BMagerMT BMagerMT commented Oct 7, 2025 •

Copy link
Copy Markdown
Contributor

My goal is to fix issues with a stream that doesn't produce data very often. The problem is that the last sent value is no longer in the cache. However, the old value not being in the cache isn't really important. But when a new value comes for a stream that value is lost because when a QueueCacheMissException occurs and the cursor is set to start at the newest message and therefore skips the message that was just added, but is actually in the cache.

See https://github.com/BMagerMT/OrleansStreamingIssue as an example that produces this problem.

The issue is this fix is not great as it is parsing the token from the exception. However, there doesn't seem to be a way to create a cursor that starts with the oldest entries.

Microsoft Reviewers: Open in CodeFlow

@BMagerMT

BMagerMT commented Oct 7, 2025

Copy link
Copy Markdown
Contributor Author

Should fix #9332

@ReubenBond ReubenBond changed the title Recover from queue cache miss with oldest data instead of newest. fix(streaming): recover cache misses from oldest data Aug 21, 2026
@ReubenBond
ReubenBond force-pushed the recover-from-queue-cache-miss-with-oldeset-data branch from 9717779 to 7a7c2e2 Compare August 21, 2026 17:53
@ReubenBond
ReubenBond marked this pull request as ready for review August 21, 2026 22:28
Copilot AI lite review requested due to automatic review settings August 21, 2026 22:28
@ReubenBond
ReubenBond self-requested a review as a code owner August 21, 2026 22:28

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

This PR adjusts persistent stream consumption behavior to recover from queue cache misses by resuming from the oldest available cached token (when available), addressing scenarios where infrequent streams can otherwise skip newly arrived messages after a cache miss.

Changes:

  • Extend QueueCacheMissException to carry the typed low/oldest token (when constructed with typed tokens) for recovery logic.
  • Update PersistentStreamPullingAgent to resume using the exception’s low token after a cache miss instead of defaulting to a null token.
  • Add tests validating that cache-miss recovery resumes from the oldest available token when present and falls back to the default cursor behavior when not.
Show a summary per file
File Description
test/Orleans.Streaming.Tests/StreamingTests/PersistentStreamPullingAgentTests.cs Adds coverage for cache-miss recovery behavior and validates cursor token selection.
src/Orleans.Streaming/QueueAdapters/QueueCacheMissException.cs Adds an internal typed low-token hook to avoid relying on parsing string tokens for recovery.
src/Orleans.Streaming/PersistentStreams/PersistentStreamPullingAgent.cs Uses the typed low token from QueueCacheMissException to resume consumption from the oldest available cached position.

Review details

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

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

@github-actions

github-actions Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 81.82% (106,320 / 129,937) 81.91% (106,420 / 129,922) -0.0864 pp
Branches 70.89% (30,327 / 42,780) 70.97% (30,359 / 42,780) -0.0748 pp

Report-only conclusion: regressed.

The current-main baseline is commit 4d301ee0e8 and uses the same reviewed coverage matrix.

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

@ReubenBond
ReubenBond force-pushed the recover-from-queue-cache-miss-with-oldeset-data branch 2 times, most recently from 626237c to 6965da7 Compare September 3, 2026 16:55
@ReubenBond
ReubenBond force-pushed the recover-from-queue-cache-miss-with-oldeset-data branch from 6965da7 to f7f4e79 Compare September 3, 2026 18:37
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.

3 participants