Hey gRPC,

I am working in *grpc-java *and looking for a way to access all of my 
currently-open root channels.
I am aware of Channelz's existence, perhaps that would help? But I have so 
far been unable to find documentation to that effect (i.e. fetching all 
living channels, regardless of OkHttp/Netty implementation).

Some of our gRPC services make use of Google's Cloud APIs for Java and so 
they have their own ManagedChannel connections up to, say, Firestore and 
Cloud Logging.

When shutting down our server, it often closes the active connections as 
the JVM exits, rather than giving them time to exit gracefully (this could 
be some implementation problem on our side, but we have encountered other 
people with this same issue).

This isn't much of an issue in production, where servers are long-lived and 
rarely shut down with live traffic in play. However, in our testsuites, we 
are encountering this exception which is causing other problems, like 
unreported coverage (missing coverage lines for gRPC services):

Feb 21, 2019 8:05:57 PM 
io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference 
cleanQueue

SEVERE: *~*~*~ Channel ManagedChannelImpl{logId=11, target=
*firestore.googleapis.com:443*} 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)

at 
io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:44)

at 
io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:419)

at 
com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:254)

at 
com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:165)

at 
com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:157)

at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:157)

at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:122)

at 
com.google.cloud.firestore.spi.v1beta1.GrpcFirestoreRpc.<init>(GrpcFirestoreRpc.java:121)

at 
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:80)

at 
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:72)

at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:509)

at 
com.google.cloud.firestore.FirestoreOptions.getFirestoreRpc(FirestoreOptions.java:315)

at com.google.cloud.firestore.FirestoreImpl.<init>(FirestoreImpl.java:76)

at 
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:63)

at 
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:56)

at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:497)

at io.[ REDACTED ].impl.FirestoreService.<init>(FirestoreService.kt:451)

        [... more frames ...]

at 
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:369)

at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:275)

at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:239)

at 
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:160)

at 
org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:373)

at 
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:334)

at 
org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:119)

at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:407)

This isn't specific to Firestore, this is just one example, although they 
are always related to Google Cloud APIs.

Is there a known way to avoid this issue, or at the very least, a way to 
query gRPC Java for any active channels that need to be shut down? Thank 
you in advance for your help.

(BTW I am posting here because the Firestore team did not seem to have an 
answer, and we have other places where this might occur, like our own use 
of our internal gRPC client within our gRPC server. So I am hoping there is 
a general gRPC-layer solution for gracefully closing active channels 
en-masse).


Thank you in advance for your help
Sam

-- 





This message (and any associated files) may contain confidential 
and/or privileged information. If you are not the intended recipient or 
authorized to receive this for the intended recipient, you must not use, 
copy, disclose or take any action based on this message or any information 
herein. If you have received this message in error, please advise the 
sender immediately and delete this message. Thank you for your cooperation.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/8248b463-bf58-4947-8203-d360d7076772%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to