Stream AddSubscriber/RemoveSubscriber invocations on producer grain shouldn't keep it alive
Hi,
I've found a major 'grains-leak' in my cluster.
The reason:
Short lived grains which produced events on an active stream (SMS).
This stream is being actively subscribed/unsubscribed by consumers, that in turns invokes AddSubscriber/RemoveSubscriber on the producer grains.
These invocations are delaying the deactivation of these grains.
This is very unexpected behaviour. These are indirect invocations that the developers shouldn't be aware of.
Workaround: manually invoke DeactivateOnIdle.
I believe that AddSubscriber/RemoveSubscriber shouldn't affect the GC collection time.
Moreover, I think grains should have an attribute on methods stating they're not affecting the GC time. It can be useful in some cases.
See SkipUpdateLastAccess in Orbit https://github.com/orbit/orbit/wiki/Concepts%3A-Useful-Annotations (thank to @SebastianStehle #5281).
Big thanks to @seniorquico and @jason-bragg which helped me a lot in gitter to figure it out. @seniorquico actually took his time to write a test case which helped clarifying! The Orleans community is amazing!
Update - the 'workaround' fix greatly reduced our Production silos memory, amount of grains and grain response latency during high loads! :muscle:
I believe that solving this issue is important. Thanks!
@shlomiw Glad to hear. What exactly was the workaround that you applied?
I have a maintenance timer which manually invokes DeactivateOnIdle when the grain is no longer required. This removes the grain as a producer of the SMS stream (at PubSubRendezvousGrain). So it won’t receive AddSubscriber/RemoveSubscriber calls anymore.
Yeah this behavior is by design at the moment, But I can see how inconvenient it can be. Maybe it can be included in streaming 3.0 as one of the problems Streaming 3.0 can solve. @jason-bragg
Move it into backlog if this is OK.
@xiazen - where can I see info about Streaming 3.0? I am curious :)
it is in people's head at the moment ;p. we are so bad at documenting. Maybe @jason-bragg will be interested in put some text out.
We are marking this issue as stale due to the lack of activity in the past six months. If there is no further activity within two weeks, this issue will be closed. You can always create a new issue based on the guidelines provided in our pinned announcement.
This issue has been marked stale for the past 30 and is being closed due to lack of activity.