Closed Philipp-p closed 1 year ago
That sounds strange to me. I assume you create one observer for each bidi-request, so there shouldn't be any unaccounted for. Also this error seams unrelated to spring/this library, so you should probably check grpc java for help. But please post a link to your question here, so I can watch that thread and maybe expand my knowledge for future questions.
Sorry, that I'm unable to help. Have a nice weekend.
Thanks for the fast answer as always! I'm using the @Scope(scopeName = "grpcRequest", proxyMode = ScopedProxyMode.TARGET_CLASS)
notation above my class, so I assume there should be only one per call as per the documentation.
I'll post the link once I make the issue, probably on Monday, when I'm back at work.
Have a nice weekend as well!
You use a scoped StreamObserver bean? Then I guess I can understand the problem. The request context gets destroyed by the cancellation. I'm not sure how to delay the bean destruction (since it is bound to the grpc context cancellation).
Could you please debug that to check whether my assumption is correct?
Sorry for not getting back to you sooner. I just debugged the issue in a more basic way as you suggested and it seems you are correct. I tested this by using the Javax annotation @PreDestroy
in my StreamObserver
. The bean gets destroyed right before the onError()
call and the application logging the StatusRuntimeException: CANCELLED: client cancelled
.
This will probably allow me to circumvent the issue by using the @PreDestroy
annotated method. However if I should debug the issue in the way you have suggested, just let me know. My question remains if I should raise the issue with the grpc-java project? For my needs the workaround probably will solve my problems, but this of course feels rather unclean and a quick and dirty fix from my end.
My question remains if I should raise the issue with the grpc-java project?
Yes, IMO the on error callback belongs to the request scope and thus the grpc context should still be valid at that point. This should be a grpc-java bug. Please post a link here so I can follow the issue.
I opened the issue grpc/grpc-java#9996
As with the issue over at grpc-java. I think for my needs everything is resolved. Thanks again for your help and support with the other issue!
The context
I'm working on failure scenarios for an application. Therefore I tested what is happening if a client receives SIGKILL during an ongoing bidirectional stream.
The question
I have an ongoing bidirectional stream between my client and my server. I then terminate my client with SIGKILL. This leads to a
io.grpc.StatusRuntimeException: CANCELLED: client cancelled
and a call to myonError()
implementation of theStreamObserver
on the server-side. My issue is that the call is not executed on the sameStreamObserver
instance asonNext()
earlier. This leads to the problem that some attributes in my StreamObserver implementation arenull
during theonError()
call instead of the values I set them to earlier. This does not happen when for example an exception is thrown during theonNext()
execution. In this case theonError()
is executed on the same instance. My question here is this intended behaviour or not? Also if this is not intended, should I raise this issue with the grpc-java project or was I correct opening the issue here?Stacktraces and logs
To make my issue more clear if I log the instance (with
System.out.print("SOME STRING" + this)
) my methods are called during the bidirectional stream would look like something like this:The application's environment
Which versions do you use?
Additional information
System.out.print("SOME STRING" + this)
.onNext()
calls will be executed on the same instance, whereas theonError()
that result from theio.grpc.StatusRuntimeException: CANCELLED: client cancelled
is executed on a different instance.Any input or help is highly appreciated!