You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, Documentation on PullingProtocol says - once the consumer has subscribed to the stream it will see all events that were generated after it has subscribed (in addition, using StreamSequenceToken allows to subscribe in the past).
As described in the referenced documentation (Queue Cache), the agent delivers events from the queue cache (IQueueCache). This means that the ability of the existing persistent stream provider to replay historical data is limited to the cached data.
For instance, assume your adapter's cache caches all events less than an hour old. If this is the case, any consumer can replay data less than an hour old. If a consumer requests data older than an hour the consumer should receive a DataNotAvailable exception on the observers OnErrorAsync call.
This pattern was mainly developed for the purposes of stream processing resiliency. It allows consumers to replay recent events while recovering from transient stream processing errors. Is this type of replay sufficient for you're purposes? If so, you will need to develop an implementation of IQueueCache that can hold messages long enough to service your application's replay needs.
If my purpose is to have a stream that will purposely store the last N points of data and be able to replay that to a client requesting all data starting from EventSequenceToken(X), does it make sense to implement my own IQueueCache as you said?
Inspecting SimpleQueueCache code, it seems like that's not what the cache is made for, it seems like cache's purpose is to empty the underlying queue to relieve it and immediately purge that data once it has been "received"!? I'm not sure why the PersistenStreamPullingAgent is calling TryPurgeFromCache all the time. This last part is not very clear to me.
Another question that's probably related is, what is "IsRewindable" supposed to do in IQueueAdapter?
Thanks,
I can help document this stuff, if possible, once I understand them properly.
I see. It seems like the answer to at least my last question is in there. So, "IsRewindable" is indeed intended to indicate/control whether the stream can replay past events or not.
As I understand, the current PersistentStreamProvider, which is the main template to extend, does not support rewinding.
Do you think that's going to be implemented in the near future?
"Inspecting SimpleQueueCache code, it seems like that's not what the cache is made for"
That cache was built mainly with azure queue in mind, but it is general purpose enough to work for most any non-rewindable streams. That's why I didn't bring it up and instead suggested that you'd need to write your own cache.
"Do you think that's going to be implemented in the near future?"
Unfortunately, we do not yet have an implementation of a rewindable stream provider in Orleans. The rewind capabilities have been jointly developed with a (large) customer who is using the capabilities in production code, so the code path has had some hardening, but all customers using this capability currently must implement their own cache. We expect one or more of the rewindable caches currently being developed by customers to be contributed back to the community. We also have plans to have an implementation of a rewindable stream provider as part of Orleans. Unfortunately, I can't yet provide dates for when either of these will be available.
"I've written a summary of what I've changed in the readme file so that you wouldn't need to go through the whole code to know what I've done."
Awesome, that will help a lot :)
Want to spend more time on this, but initial feedback:
Cold cache size should probably be configurable, like the cache size.
PipeQueueAdapterReceiver seems to read from an in memory queue. Does this provider have no persistent backend queue, or am I missing something?
The messages reported during the cache purge are the same as SimpleQueueCache. There are advantages to this (as with azure queues), but for recovery reasons it would be better to report messages purged from the cold cache.
This is not something you need to concern yourself with first pass, but if the cold cache is large all messages in the cold cache will end up in Gen2. This will likely cause GC related performance issues.
Yes, it's a memory queue, it doesn't have a persistent backend. I think I can add something like Redis as a configurable backend.
Cold cache is not supposed to be purged.
Cold cache is not supposed to be garbage collected unless the stream gets deleted. I think if I use Redis, then there will be no need to keep that big queue in memory at all.
I think I shouldn't have called it "cache" because that makes it sound like it's supposed to be temporary.
Also, I'm creating another stream that will work like a dictionary. It will store id=>value and update values when the id already exists. When a client connects it will replay the dictionary then start streaming new messages like a normal stream.
Then I think there may be a bug in your cache. The cold cache has a max size, and when it becomes larger than the max size, the oldest messages are deleted. I consider this a 'purge'. Am I mistaken?
"You can later think of using ESE to persist dictionary on disk."
Storing the 'cold' cache to disk may be practical for your needs, but most users of the PersistentStreamProvider use it to read from some existing backend persistent queue, so persisting the 'cold' data (again), in most cases, won't really make sense.
The PersistentStreamProvider, as is, is sufficient for real-time (or near real-time) event processing with recovery, but it has no mechanism for rereading from the persistent queue if data is requested that is no longer in the cache. The cold cache you've introduced can extend the size of the cache, improving the recoverability, working within the fundamental limitations in the existing architecture. As a general solution, it's a good solution, assuming the purge behaviors are worked out.
Then I think there may be a bug in your cache. The cold cache has a max size, and when it becomes larger than the max size, the oldest messages are deleted. I consider this a 'purge'. Am I mistaken?
You are right.
Storing the 'cold' cache to disk may be practical for your needs, but most users of the PersistentStreamProvider use it to read from some existing backend persistent queue, so persisting the 'cold' data (again), in most cases, won't really make sense.
In our use case, we are dealing with a lot of timeseries data and normally we want to store everything since the start of the day. I think in our case it makes sense to persist the queue on disk and reread it if the stream is shutdown for some reason and comes back up again. Any comments on this?
The PersistentStreamProvider, as is, is sufficient for real-time (or near real-time) event processing with recovery, but it has no mechanism for rereading from the persistent queue if data is requested that is no longer in the cache.
I can do that in the IQueueCache e.g. save old data to disk with an ID that is a combination of the stream GUID and cache number.
we will likely first finish the 'rewind for recovery' story, using a rewindable cache capable of caching large amounts of data. Rewinding back to the persistent queue is a longer term goal
So, let's say I want to develop 'proper' rewinding using the underlying physical queue rather than my big 'cold' cache. Is that currently possible without changing the source of Orleans itself?
When implementing a PersistentStreamProvider, I don't get the sequence token that the client sent as input until I'm already inside the cache, so past the point where I can use the physical underlying queue to rewind. Am I missing something?
The fact that this works for SMS but not using your stream provider seems to hint towards an issue in the adapter implementation. I suggest adding logging to the inputs and outputs of the adapter and ensuring the data is flowing as expected. Specifically:
If you've demonstrated that data is flowing correctly, please reference the grain that is acting strange and I'll take a look. I'm not familiar with your application code, so details help.
This case is serializing an IAsyncStream from a grain to a client, then calling subscribe on the grain's stream. The impl of IAsyncStream is serializable, but we've no testing around that scenario.
Does it work if you subscribe to a stream acquired directly from the provider.
Thanks for the suggestion, but subscribing directly using the provider didn't work either. I also marked the class as Serializable and tried adding the project containing the class to the server project references (so it knows how to serialize it).
I've updated the code to do that, so if you wish to try it yourself you can simply just clone and run.
So, just to make sure I understand, is the stream adapter including its receiver and cache created at every end of the stream (every consumer/producer)?
"stream adapter including its receiver and cache created at every end of the stream (every consumer/producer)?"
Not exactly. The adapter is created for every instance of the stream provider.
Receivers and caches for a queue are created on the silos responsible for reading from those queues.
Since in your adapter you are writing to and reading from an in-memory queue, the client will write to a different in memory queue from the one the receiver on the silo is reading from.
Same thing happens on multiple silos. All grains on a silo will write their events to the in-memory queue on their silo, but other silos have no way of getting those messages. When a queue is assigned to a silo, the receiver and cache will be created for that queue, but the only messages in that queue will be the ones created on that silo. Further, all messages sent to queues assigned to other silos will sit in the in-memory queue unread because the silo has no receiver or cache setup for queues it's not responsible for.
An in-memory queue is only viable for a single silo deployment with no client use of the streams. This can be useful for test purposes, but not much else.
Thanks for the clarification, I think I understand now.
I think it would be great if we could have some other way of communication (chat). Because of time difference and lots of small queries, it makes more sense if we could have a quick conversation some time if that's possible. Are you ok with that ? if yes, then do you use any chat service?
@angshuman-agarwal
To you're original question about replying historical messages, depending on your scenarios, the introduction of the PooledQueueCache may solve some of your issues. Also the test cases introduced in "Stream Recovery Tests #1289" should help one become familiar with the rewind/recovery capabilities currently supported.
Activity
jason-bragg commentedon Nov 4, 2015
As described in the referenced documentation (Queue Cache), the agent delivers events from the queue cache (IQueueCache). This means that the ability of the existing persistent stream provider to replay historical data is limited to the cached data.
For instance, assume your adapter's cache caches all events less than an hour old. If this is the case, any consumer can replay data less than an hour old. If a consumer requests data older than an hour the consumer should receive a DataNotAvailable exception on the observers OnErrorAsync call.
This pattern was mainly developed for the purposes of stream processing resiliency. It allows consumers to replay recent events while recovering from transient stream processing errors. Is this type of replay sufficient for you're purposes? If so, you will need to develop an implementation of IQueueCache that can hold messages long enough to service your application's replay needs.
gabikliot commentedon Nov 5, 2015
#756
amamh commentedon Nov 5, 2015
@jason-bragg
If my purpose is to have a stream that will purposely store the last N points of data and be able to replay that to a client requesting all data starting from EventSequenceToken(X), does it make sense to implement my own IQueueCache as you said?
Inspecting SimpleQueueCache code, it seems like that's not what the cache is made for, it seems like cache's purpose is to empty the underlying queue to relieve it and immediately purge that data once it has been "received"!? I'm not sure why the PersistenStreamPullingAgent is calling TryPurgeFromCache all the time. This last part is not very clear to me.
Another question that's probably related is, what is "IsRewindable" supposed to do in IQueueAdapter?
Thanks,
I can help document this stuff, if possible, once I understand them properly.
amamh commentedon Nov 5, 2015
@gabikliot
I see. It seems like the answer to at least my last question is in there. So, "IsRewindable" is indeed intended to indicate/control whether the stream can replay past events or not.
As I understand, the current PersistentStreamProvider, which is the main template to extend, does not support rewinding.
Do you think that's going to be implemented in the near future?
jason-bragg commentedon Nov 5, 2015
That cache was built mainly with azure queue in mind, but it is general purpose enough to work for most any non-rewindable streams. That's why I didn't bring it up and instead suggested that you'd need to write your own cache.
Unfortunately, we do not yet have an implementation of a rewindable stream provider in Orleans. The rewind capabilities have been jointly developed with a (large) customer who is using the capabilities in production code, so the code path has had some hardening, but all customers using this capability currently must implement their own cache. We expect one or more of the rewindable caches currently being developed by customers to be contributed back to the community. We also have plans to have an implementation of a rewindable stream provider as part of Orleans. Unfortunately, I can't yet provide dates for when either of these will be available.
amamh commentedon Nov 6, 2015
@jason-bragg
I've implemented my own IQueueCache which enables replays. I'll post it later today (London time).
jason-bragg commentedon Nov 6, 2015
@amamh 👍
Shiny! Can't wait to see it!
amamh commentedon Nov 7, 2015
@jason-bragg
https://github.com/amamh/orleans-PipeStreamProvider
I've written a summary of what I've changed in the readme file so that you wouldn't need to go through the whole code to know what I've done.
Would be nice if you could give some feedback !
jason-bragg commentedon Nov 9, 2015
Awesome, that will help a lot :)
Want to spend more time on this, but initial feedback:
amamh commentedon Nov 9, 2015
@jason-bragg
I think I shouldn't have called it "cache" because that makes it sound like it's supposed to be temporary.
Also, I'm creating another stream that will work like a dictionary. It will store id=>value and update values when the id already exists. When a client connects it will replay the dictionary then start streaming new messages like a normal stream.
angshuman-agarwal commentedon Nov 10, 2015
@amamh You can later think of using ESE to persist dictionary on disk. Managed implementation is HERE
jason-bragg commentedon Nov 10, 2015
@amamh
Then I think there may be a bug in your cache. The cold cache has a max size, and when it becomes larger than the max size, the oldest messages are deleted. I consider this a 'purge'. Am I mistaken?
Storing the 'cold' cache to disk may be practical for your needs, but most users of the PersistentStreamProvider use it to read from some existing backend persistent queue, so persisting the 'cold' data (again), in most cases, won't really make sense.
The PersistentStreamProvider, as is, is sufficient for real-time (or near real-time) event processing with recovery, but it has no mechanism for rereading from the persistent queue if data is requested that is no longer in the cache. The cold cache you've introduced can extend the size of the cache, improving the recoverability, working within the fundamental limitations in the existing architecture. As a general solution, it's a good solution, assuming the purge behaviors are worked out.
amamh commentedon Nov 10, 2015
@jason-bragg
You are right.
In our use case, we are dealing with a lot of timeseries data and normally we want to store everything since the start of the day. I think in our case it makes sense to persist the queue on disk and reread it if the stream is shutdown for some reason and comes back up again. Any comments on this?
I can do that in the IQueueCache e.g. save old data to disk with an ID that is a combination of the stream GUID and cache number.
8 remaining items
amamh commentedon Nov 11, 2015
@jason-bragg
So, let's say I want to develop 'proper' rewinding using the underlying physical queue rather than my big 'cold' cache. Is that currently possible without changing the source of Orleans itself?
When implementing a PersistentStreamProvider, I don't get the sequence token that the client sent as input until I'm already inside the cache, so past the point where I can use the physical underlying queue to rewind. Am I missing something?
amamh commentedon Nov 11, 2015
@jason-bragg
If you don't mind, there is another issue I'm having. I didn't want to open a new 'issue' for it, it's probably something small that I'm missing.
In my implementation:
https://github.com/amamh/orleans-PipeStreamProvider
I cannot get it to work with a non-grain observer. You can simply clone the repo and see it yourself. The logs don't show any issues.
It works fine when using the SimpleMessageStreamProvider instead.
jason-bragg commentedon Nov 11, 2015
The fact that this works for SMS but not using your stream provider seems to hint towards an issue in the adapter implementation. I suggest adding logging to the inputs and outputs of the adapter and ensuring the data is flowing as expected. Specifically:
IQueueAdapter.QueueMessageBatchAsync
IQueueCacheCursor.GetCurrent
If you've demonstrated that data is flowing correctly, please reference the grain that is acting strange and I'll take a look. I'm not familiar with your application code, so details help.
amamh commentedon Nov 11, 2015
Sorry, maybe I wasn't clear. It's not a grain, it's the simple test class in Client/Program.cs
It works fine when using a grain, but not when using a "normal" object.
jason-bragg commentedon Nov 11, 2015
Ah, I see.
This case is serializing an IAsyncStream from a grain to a client, then calling subscribe on the grain's stream. The impl of IAsyncStream is serializable, but we've no testing around that scenario.
Does it work if you subscribe to a stream acquired directly from the provider.
amamh commentedon Nov 11, 2015
@jason-bragg
Thanks for the suggestion, but subscribing directly using the provider didn't work either. I also marked the class as Serializable and tried adding the project containing the class to the server project references (so it knows how to serialize it).
I've updated the code to do that, so if you wish to try it yourself you can simply just clone and run.
jason-bragg commentedon Nov 11, 2015
Oh, I'm a dork.
Client and grain are in different processes, so your in-memory queue won't work. This is the same issue as the multi-silo problem.
However, I do recall asking that you add tracing to adapter inputs and outputs to verify something like this wasn't the case. :)
amamh commentedon Nov 11, 2015
@jason-bragg
I see, thanks :)
So, just to make sure I understand, is the stream adapter including its receiver and cache created at every end of the stream (every consumer/producer)?
jason-bragg commentedon Nov 11, 2015
@amamh
Not exactly. The adapter is created for every instance of the stream provider.
Receivers and caches for a queue are created on the silos responsible for reading from those queues.
Since in your adapter you are writing to and reading from an in-memory queue, the client will write to a different in memory queue from the one the receiver on the silo is reading from.
Same thing happens on multiple silos. All grains on a silo will write their events to the in-memory queue on their silo, but other silos have no way of getting those messages. When a queue is assigned to a silo, the receiver and cache will be created for that queue, but the only messages in that queue will be the ones created on that silo. Further, all messages sent to queues assigned to other silos will sit in the in-memory queue unread because the silo has no receiver or cache setup for queues it's not responsible for.
An in-memory queue is only viable for a single silo deployment with no client use of the streams. This can be useful for test purposes, but not much else.
amamh commentedon Nov 12, 2015
@jason-bragg
Thanks for the clarification, I think I understand now.
I think it would be great if we could have some other way of communication (chat). Because of time difference and lots of small queries, it makes more sense if we could have a quick conversation some time if that's possible. Are you ok with that ? if yes, then do you use any chat service?
amamh commentedon Nov 13, 2015
@jason-bragg
I opened a new issue #1022
jason-bragg commentedon Jan 19, 2016
@angshuman-agarwal
To you're original question about replying historical messages, depending on your scenarios, the introduction of the PooledQueueCache may solve some of your issues. Also the test cases introduced in "Stream Recovery Tests #1289" should help one become familiar with the rewind/recovery capabilities currently supported.
angshuman-agarwal commentedon Apr 29, 2016
Thanks. Will take a look at it.