-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Grpc-Java : make sure to call shutdown()/shutdownNow() and wait until awaitTermination #5315
Comments
This changed in recent versions of gRPC to only require shutdown(). Your code doesn't handle InterruptedException properly, and the RPC should be inside of the try block (if it throws, the channel wouldn't shutdown). |
Which version ? So the rpc in the try and only Channel.shutdown(); in a finally block + interrupt flag to true if interruptedException ?? Is it right? |
The PR was #5283 which will end up in the 1.19 release (1.18 happens next week).
Correct. |
So waiting for 1.19.. should I keep the code 'shutdown().awaitTermination(..)?? |
Hi. I switch to grpc-netty and grpc-services 1.18.0. But continue to have errors : java.lang.RuntimeException: ManagedChannel allocation site I change my client code to :
|
Same here with the String name = UUID.randomUUID().toString();
Server server = InProcessServerBuilder.forName(name).addService(service).build();
server.start();
try {
// do whatever....
} finally {
server.shutdownNow().awaitTermination();
}
|
It seems there is nothing we can do for now. Looks somewhat similar to grpc/grpc-java#5315. The test output is not hidden behind the `MuteLogging` so the problem is still apparent during the build.
Closing, since this should have long-ago been fixed. @laymain, it seems your comment wasn't seen before. You're code snippet is for a Server but the exception is for a Channel, so you still may have a bug elsewhere in your code. If anyone experiences this with gRPC v1.19 or later, then please open a new issue. |
Please answer these questions before submitting your issue.
What version of gRPC are you using?
grpc-core 1.13.1
What did you expect to see?
I saw lot ====> of .g.i.ManagedChannelOrphanWrapper : ~
*Channel ManagedChannelImpl{logId=5, target=172.30.84.17:6565} was not shutdown properly!!!*~Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
java.lang.RuntimeException: ManagedChannel allocation site
at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.(ManagedChannelOrphanWrapper.java:103)
at io.grpc.internal.ManagedChannelOrphanWrapper.(ManagedChannelOrphanWrapper.java:53)
following each errors (StatusRuntimeException)
Client code :
I start a new channel by request. Is-it correct ?
shutdown not done efficiently ?
The text was updated successfully, but these errors were encountered: