Skip to content

Conversation

@BMagerMT
Copy link
Contributor

@BMagerMT BMagerMT commented Oct 7, 2025

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
Copy link
Contributor Author

BMagerMT commented Oct 7, 2025

Should fix #9332

exceptionOccured = exc;
consumerData.SafeDisposeCursor(logger);
// start from the entry at the low token, which is the first entry we know is still in the cache.
var tokenParsed = long.TryParse(exc.Low, out var lowTokenLong);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case we are working in it is using memory streams and this seems to work. However, for other tokens even the one I used below the EventSequenceTokenV2 and EventSequenceToken both have a ToString that wouldn't work for this.

A nicer option potentially is to have a way that queueCache.GetCacheCursor can start from the lowest without passing a StreamSequenceToken. I understand that queueCache.GetCacheCursor passing null starts with the newest message makes sense for case of a new subscription.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is definitely not correct and just appeared to be working as the string parsing doesn't match the sequence number ToString().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with the parsing has been fixed and tested to fix the problem, but of course the parsing is still not a nice solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant