question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grpc-Java : make sure to call shutdown()/shutdownNow() and wait until awaitTermination

See original GitHub issue

Please answer these questions before submitting your issue.

What version of gRPC are you using?

grpc-core 1.13.1

image

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.<init>(ManagedChannelOrphanWrapper.java:103) at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:53)

following each errors (StatusRuntimeException)

Client code :

ManagedChannel channel = ManagedChannelBuilder.forAddress(this.host, this.port).usePlaintext().intercept(interceptors).build();
    T t = runner.apply(stubSupplier.apply(channel).withDeadlineAfter(timeout, TimeUnit.MILLISECONDS));
    try {
      channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
      return t;
    } catch (InterruptedException e) {
      throw new IllegalStateException("Error happened during shutdown of validator gRPC channel", e);
    }

I start a new channel by request. Is-it correct ?

shutdown not done efficiently ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
laymaincommented, May 2, 2019

Same here with the InProcessServerBuilder and gRPC 1.20.0

String name = UUID.randomUUID().toString();
Server server = InProcessServerBuilder.forName(name).addService(service).build();
server.start();
try {
    // do whatever....
} finally {
    server.shutdownNow().awaitTermination();
}
Channel ManagedChannelImpl{logId=44, target=directaddress:///8158b613-fec5-4656-a664-16c689b56f3b} 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.<init>(ManagedChannelOrphanWrapper.java:94)
	at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:52)
	at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:43)
	at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:527)
2reactions
carl-mastrangelocommented, Feb 4, 2019

The PR was https://github.com/grpc/grpc-java/pull/5283 which will end up in the 1.19 release (1.18 happens next week).

So the rpc in the try and only Channel.shutdown(); in a finally block + interrupt flag to true if interruptedException ?? Is it right?

Correct.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make sure to call shutdown()/shutdownNow() and wait until ...
Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true. java.lang.RuntimeException: ManagedChannel ...
Read more >
Channel ManagedChannelImpl was not shut down properly
(ManagedChannelOrphanWrapper.java:159) Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
Read more >
io.grpc.Server.shutdownNow java code examples - Tabnine
Bind and start the server. awaitTermination. Waits for the server to become terminated, giving up if the timeout is reached. shutdown. Initiates an...
Read more >
grpc/grpc - Gitter
Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true. java.lang.RuntimeException: ManagedChannel allocation site
Read more >
Grpc channel is not closed when there is exception ... - Apache
Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true. java.lang.RuntimeException: ManagedChannel allocation site at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found