Azure Queues Orleans.Streams.QueueCacheMissException
We are using 2.0.0 with Azure Queues we are getting a QueueCacheMissException on some of our streams, while other streams are working as expected. We are basically using the default configuration to use streams with a small load. I found some info on configuring a cache size, but I havent found any examples in the Tests or Samples.
Item not found in cache. Requested: [EventSequenceTokenV2: SeqNum=28, EventIndex=0],
Low: [EventSequenceTokenV2: SeqNum=29, EventIndex=0], High: [EventSequenceTokenV2:
SeqNum=29, EventIndex=0]
Exception while retrying the 0th time reading from queue default-2
Configuration:
.AddAzureQueueStreams<AzureQueueDataAdapterV2>("Default", ob => ob.Configure(options =>
{
options.ConnectionString = queueConnection;
}))
there's two AddAzureQueueStream extension methods, one took a Action<AzureQueueOptions> which only let you configure azure queue specific stuff, but left other settings to be the default value.
Another one took a Action<ClusterClient(Silo)AzureQueueStreamConfigurator>, which opens more configuration to you, so for your case, if you want to configure cache size: below is an example
.AddAzureQueueStreams<AzureQueueDataAdapterV2>(StreamProvider, configurator=>configurator.ConfigureAzureQueue(
ob => ob.Configure( options=>
{
options.ConnectionString = yourConnectionString
}))
.ConfigureCache(biggerCacheSize))
Thanks for the info. I don't understand why our cache size would need to be increased. It was a very small load, and our messages are pretty small. Is there something I can look at to see why we filled the cache?
Oh I thought you want to configure your cache size to be bigger, maybe I misunderstood you.To see if you filled cache, try see if you see CacheFullException in your log
I'm not seeing any CacheFullException, just the QueueCacheMissException. When I researched this exception I found that some are setting a bigger cache size. I'm just trying to figure out if it is normal to set a larger cache size or if this is an indicator of another problem within our system.
When you say small load, can you hint at some rough numbers? For instance, about how many streams are active at any point in time? What does the throughput per stream look like (in events per second)? How long does a stream usually live? Asking because I’ve found that the idea of ‘small load’ can vary greatly from person to person. 😊
In general, cache miss exceptions shouldn’t happen except under error conditions, though the behaviors and causes can be stream provider specific.
If you do not have a handler for the OnErrorAsync, I’d start with adding one that logs any errors sent to the grain. This can help correlate the error with grain activity to help understand how the system got into this state.
The most common cause of cache misses using azure queues (from what I’ve seen) is when users pass a sequence token to a stream when resuming processing. This is the norm for recoverable streams, but azure queue streams are not recoverable, so sequence tokens passed to a resume will usually lead to a cache miss.
A silo outage, which triggers a queue to be moved to a different silo may also cause a cache miss.
Cache size changes ‘shouldn’t’ really effect cache misses and the error indicates that there is only a single message in the cache.
Low: [EventSequenceTokenV2: SeqNum=29, EventIndex=0], High: [EventSequenceTokenV2: SeqNum=29, EventIndex=0]
These are the lowest and highest events in the cache. We can see that they are the same, so there is only a single event. What’s not clear is why an earlier message is being requested.
At the time we only had ~5 producers sending 1 message per minute to 10 different consumers. We did discover a bug in our OnNext that was throwing an exception. We no longer throw the exception, but we are still seeing these errors. I just added the code to log in the OnErrorAsync so we can see exactly what is going on.
@dsarfati Any update?
We were not able to easily resolve this with code. We ended up taking down the system for a short period of time and completely clearing the queue storage account. Our best guess is that there was either an unhandled exception that was thrown in the stream callback that caused this loop or that there was a change to the code base that caused the generated interface id to change, resulting in a never-ending loop of stream providers attempting to process a message with the old interface id.
Any Update?
close it now. feel free to reopen. Sorry we couldn't help much.