-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Serverside interceptors throws KeyNotFound exception #1869
Comments
Must be a bug related to grain extensions not being handled correctly. |
Who is throwing KeyNotFound? Global Serverside interceptor? Can you provide the stack trace? And what if you just remove the interceptor, but still use streams? Does that work? Finally, if that does work with streams without interceptor, the fault may be more related to interceptor rather than to streams. What is your interceptor doing? |
The streams works without the interceptor. Currently the interceptor only does what is shown in the code snippet above. I initially thought that it might be something that I am doing that is causing the issue, so i removed all the code and only added a Stack trace
|
Ohh, I see. Basicaly, what @sergeybykov wrote: "Must be a bug related to grain extensions not being handled correctly." More exactly: A bug related to interceptor not using the invoker correctly in combination with extensions. |
@ReubenBond , why are we passing Maybe the fix is as simple as that? I can't really figure out the logic in |
@gabikliot I tried the fix you suggested on a local copy of Orleans, I am still getting the error. |
@Dewaldf is that the entire/correct stack trace? I don't see the exception there. I'll try to create a repro test case from your code and have a look. @gabikliot that code is fairly ugly in order to preserve as much efficiency and ensure consumers only 'pay for what you use' as much as possible. I'll submit a PR to clean up some naming and comments to make it more apparent what's going on. To answer your question, if the grain implements // If the target has a grain-level interceptor or there is a silo-level interceptor, intercept the call.
var shouldCallSiloWideInterceptor = SiloProviderRuntime.Instance.GetInvokeInterceptor() != null && target is IGrain;
var intercepted = target as IGrainInvokeInterceptor;
var grainHasInterceptor = intercepted != null;
if (grainHasInterceptor || shouldCallSiloWideInterceptor)
{
// Get an invoker which delegates to the grain's IGrainInvocationInterceptor implementation.
// If the grain does not implement IGrainInvocationInterceptor, then the invoker simply
// delegates calls to the provided invoker.
var interceptedInvoker =
this.interceptedMethodInvokers.GetOrCreate(
target.GetType(),
request.InterfaceId,
invoker);
var methodInfo = interceptedInvoker.GetMethodInfo(request.MethodId);
if (shouldCallSiloWideInterceptor)
{
// There is a silo-level interceptor and possibly a grain-level interceptor.
// As a minor optimization, only pass the intercepted invoker if there is a grain-level
// interceptor.
resultTask = SiloProviderRuntime.Instance.CallInvokeInterceptor(
methodInfo,
request,
target,
grainHasInterceptor ? interceptedInvoker : invoker);
}
else
{
// The grain has an interceptor, but there is no silo-wide interceptor.
resultTask = intercepted.Invoke(methodInfo, request, invoker);
}
}
else
{
// The call is not intercepted at either the silo or the grain level, so call the invoker
// directly.
resultTask = invoker.Invoke(target, request);
}
resultObject = await resultTask; Does that make it clearer? I changed the call to |
Fix #1869. Grain Extensions + method interception should function correctly
…ectly with IGrainInvokeInterceptor (cherry picked from commit 332e20a)
Hi, I have implemented the following global serverside interceptor.
This works well when you have grains calling other grains, but as soon as you have a grain that subscribes to a stream then a
KeyNotFoundException
gets thrown. If you just call the grain normally without using streams everything works 100%.Below is an example of the grain subscribing to the stream that is causing the exception to be thrown
The text was updated successfully, but these errors were encountered: