Skip to content

Commit

Permalink
fix:Orleans Streaming: in [SetCursor] method, If last purged token do…
Browse files Browse the repository at this point in the history
…es not exists, do not throw an exception, just start from the oldest message in cache dotnet#8863
  • Loading branch information
gusuchengnan committed Mar 13, 2024
1 parent 820a7be commit 6d8a268
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Orleans.Streaming/Common/PooledCache/PooledQueueCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ private void SetCursor(Cursor cursor, StreamSequenceToken sequenceToken)
if (oldestMessage.Compare(sequenceToken) > 0)
{
// Check if we missed an event since we last purged the cache
if (this.lastPurgedToken.TryGetValue(cursor.StreamId, out var entry) && sequenceToken.CompareTo(entry.Token) >= 0)
var isLastPurged = this.lastPurgedToken.TryGetValue(cursor.StreamId, out var entry);
if (!isLastPurged || sequenceToken.CompareTo(entry.Token) >= 0)
{
// If the token is more recent than the last purged token, then we didn't lose anything. Start from the oldest message in cache
// If last purged token does not exists, or the token is more recent than the last purged token, then we didn't lose anything. Start from the oldest message in cache
cursor.State = CursorStates.Set;
cursor.CurrentBlock = oldestBlock;
cursor.Index = oldestBlock.Value.OldestMessageIndex;
Expand Down

0 comments on commit 6d8a268

Please sign in to comment.