The warning you see is triggered by the garbage collector (via a WeakRef),
so likely the Channel won't show up in Channelz when you see the message.
If you don't have references to these channels, then it won't be possible
to shut them down directly. If you can create them (such as in your
tests), we provide some helper classes to auto create and shut them down
such as GrpcServerRule.
One other thing: you could (not saying it's a good idea), silence these
logs for your tests. I would strongly encourage you to file bugs to the
projects that create the channels, (which is why we include the creation
site stack trace), but mute them if you can't take any action in response
to them.
On Friday, February 22, 2019 at 12:05:20 PM UTC-8, Sam G wrote:
>
> It appears the stacktrace I posted is written in white font. Apologies for
> that... here it is again, but this time, legibly:
>
>
> Feb 21, 2019 8:05:57 PM
> io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference
> cleanQueue
>
> SEVERE: *~*~*~ Channel ManagedChannelImpl{logId=11,
> target=*firestore.googleapis.com:443
> <http://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)
>
>
> On Friday, February 22, 2019 at 11:56:13 AM UTC-8, Sam G wrote:
>>
>> 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
>> <http://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
>>
>
--
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/dacef987-a86e-4b1b-9aa2-0d54c12eabb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.