'Extension not installed' exception on stream producer grain
from gitter: Having stream configured like this:
config.AddSimpleMessageStreamProvider(Constants.SimpleMessagingStreamProvider, fireAndForgetDelivery: true);
Such code
[StorageProvider(ProviderName = "OrderTrackerGrainStorageProvider")]
public class OrderTrackerGrain : Grain<OrderLogGrainState>, IOrderTrackerGrain
{
private IAsyncObserver<OrderEvent> _out;
public override Task OnActivateAsync()
{
_out = GetStreamProvider(Constants.SimpleMessagingStreamProvider).GetStream<OrderEvent>(this.GetPrimaryKey(), Constants.OrderEventStream);
return base.OnActivateAsync();
}
public async Task<OperationResult> Add(OrderEvent ev)
{
State.Events.Add(ev);
await WriteStateAsync();
await _out.OnNextAsync(ev);
return OperationResult.Success;
}
public Task<OperationResult<List<OrderEvent>>> GetEvents() => OperationResult.TaskFromResult(State.Events);
}
sometimes throws this exception:
Extension not installed on grain Orders.OrderTrackerGrain attempting to invoke type Orleans.Streams.OrleansCodeGenStreamProducerExtensionMethodInvoker from invokable Orleans.Runtime.ActivationData for message IsAlwaysInterleave NewPlacement Request S10.250.0.11:1000:249209849*grn/716E8E94/93552eb0+SimpleMessagingStreamProvider_orderevents@7b5be0a1->S10.250.0.6:1000:249209934*grn/4F31C36A/93552eb0@009e8d83 #25158: global::Orleans.Streams.IStreamProducerExtension:AddSubscriber() Exc level 0: Orleans.Runtime.GrainExtensionNotInstalledException: Extension not installed on grain Orleans.Workers.Orders.OrderTrackerGrain attempting to invoke type Orleans.Streams.OrleansCodeGenStreamProducerExtensionMethodInvoker from invokable Orleans.Runtime.ActivationData
This exception indicates that the target Orders.OrderTrackerGrain that at some point subscribed to the stream most likely got deactivated, and didn't resume its subscription to the stream (from inside its OnActivateAsync) when it got activated again by the stream event. The code of OnActivateAsync above doesn't include any resume statement.
In this code snippet I don't see where the grain subscribes to a stream. I suspect it does somewhere else, but that code assumes that the grain stays activated the whole time, which is generally not the case, as idle grains get deactivated due to inactivity and in case of certain failures.
@sergeybykov This grain does not subscribe to that stream, It only publishes to it. But exception says:
GrainExtensionNotInstalledException: Extension not installed on grain Orleans.Workers.Orders.OrderTrackerGrain.
On the other end there are some [ImplicitStreamSubscription] grains reading from this stream:
[ImplicitStreamSubscription(Constants.OrderEventStream), Reentrant]
public class PushNotificationEventsGrain : Grain, IPushNotificationEventsGrain
{
private IAsyncObservable<OrderEvent> _in;
public override async Task OnActivateAsync()
{
_in = GetStreamProvider(Constants.SimpleMessagingStreamProvider).GetStream<OrderEvent>(this.GetPrimaryKey(), Constants.OrderEventStream);
Does this exception really mean some problems with receivers (even when it mentions only producer grain)?
And the most strange part is that exception only pops rarely. If it was any miscofiguration - we'd see it firing on every request. But in fact it only spots rarely in logs and we cannot catch its source.
Thanks, it's more clear now. The SMS stream case a little bit weird - producer grains get extensions installed because they need to be notified (under the covers) about new subscribers.
@xiazen Can you tell in what circumstances in this scenario Extension not installed can happen?
The extension installed error on a producer grain should not be happening if the grain is shutdown properly, but I suspect it may be possible after a crash. Is this happening only after silo crashes (or forced kill, basically any non-graceful shutdown)? If so I would consider that a bug which we should fix.
More Context For the streaming infrastructure to talk to a grain it installs 'grain extensions'. If these extensions are not installed the stream infrastructure can't talk to the grain and the error your seeing will be generated. For producers, the grain extension is installed when a producer produces it's first event. Producers are unregistered upon deactivation, so they should not be taking part in streaming until reactivated.
Theory However, (and this is my theory on this issue, which I need to confirm) if they are not properly shutdown, they may remain registered and receive calls from the streaming infrastructure which they can't handle due to the extension not being installed.
Workaround EDIT: Ignore this workaround, it should not be necessary. Assuming my theory is correct, the only workaround I can come up with (at this time, and within what the current code does) is that you may need to generate some sort of 'no-op' event on the stream upon activation which consumers would need to ignore. By generating an event within the onActivateAsync the producer extension will be forcibly installed. The OnError or OnCompleted calls 'should' also have the same effect.
@justmara
"sometimes throws this exception"
What throws this exception?
Looking at the code, it looks like the extension not installed, at least for streaming purposes, is just a warning that will show up in the logs. It should not be showing up at the application layer. That is, it should not effect any of the streaming grain behaviors. It's just a warning letting you know that this happened. The streaming infrastructure should clean this up without effecting the application layer. Is this not the case?
@jason-bragg as I already mentioned - we only see this message rarely popping in logs without any context info. So question was 'do we need to worry about this log exceptions'. Now when we've added tracing of activity.id we've managed to catch up linked log messages:
2017-12-06T10:06:26.009 Warning
Extension not installed on grain Lama.Orleans.Workers.Orders.OrderTrackerGrain attempting to invoke type Orleans.Streams.OrleansCodeGenStreamProducerExtensionMethodInvoker from invokable Orleans.Runtime.ActivationData for message IsAlwaysInterleave Request S10.250.0.6:1000:250242910*grn/716E8E94/86ba52ab+SimpleMessagingStreamProvider_orderevents@6edf4da6->S10.250.0.6:1000:250242910*grn/4F31C36A/86ba52ab@3bcdda83 #34065: global::Orleans.Streams.IStreamProducerExtension:AddSubscriber()
2017-12-06T10:06:26.022Z Warning
Producer PubSubPublisherState:StreamId=orderevents-0532f4bd-1078-464f-ab52-ba865d0b7373-SimpleMessagingStreamProvider,Producer=GrainReference:*grn/4F31C36A/86ba52ab. on stream orderevents-0532f4bd-1078-464f-ab52-ba865d0b7373-SimpleMessagingStreamProvider is no longer active - permanently removing producer.
these two have same OperationId so these messages were written in context of same call.
First of all we've found em in ApplcationInsights logs as Exceptions, without any severity level so this is why this question popped up in gitter and then were translated to issue here.
@justmara Understood. Thanks for clarification, I should have read more closely.
do we need to worry about this log exceptions
No. They are warnings indicating unexpected behaviors which should only occur after ungraceful shutdowns. The streaming infrastructure should clean these up for you.
However, if you are only using implicit subscriptions (no explicit subscriptions) you can configure SMS to use the implicit only pubsub system, which will remove these entirely as well as removing the need to register a storage provider for the pubsub system.
options.ClusterConfiguration.AddSimpleMessageStreamProvider(StreamProviderName, false, true,
StreamPubSubType.ImplicitOnly);
close this issue since concern is answered. feel free to reopen if having further questions