Repository navigation
PubSub: grpc Uncaught exception in the SynchronizationContext. Panic! - Could not find LoadBalancer pick_first #4700
Copy link
Copy link
Closed
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
- Specify the API: PubSub
- OS type and version: Docker image gradle:5.2-jdk11-slim (also happens with jdk8 and other images)
- Java version: jdk11 and jdk8
- google-cloud-java version(s): 1.62.0 and above (tested with 1.65.0, too)
Steps to reproduce
- Use google-cloud-pubsub library with version 1.62.0 or above as dependency
- Create a subscription in own code (see code example below)
Code example
ProjectSubscriptionName subscriptionName = ProjectSubscriptionName.of(projectId, subscriptionId);
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
subscriptionAdminClient.getSubscription(subscriptionName); // Exception is thrown in this line
}
...Stack trace
Mar 19, 2019 6:20:52 PM io.grpc.internal.ManagedChannelImpl$1 uncaughtException
SEVERE: [io.grpc.internal.ManagedChannelImpl-1] Uncaught exception in the SynchronizationContext. Panic!
java.lang.IllegalStateException: Could not find LoadBalancer pick_first. The build probably threw away META-INF/services/io.grpc.LoadBalancerProvider
at io.grpc.internal.AutoConfiguredLoadBalancerFactory$AutoConfiguredLoadBalancer.<init>(AutoConfiguredLoadBalancerFactory.java:74)
at io.grpc.internal.AutoConfiguredLoadBalancerFactory.newLoadBalancer(AutoConfiguredLoadBalancerFactory.java:45)
at io.grpc.internal.ManagedChannelImpl.exitIdleMode(ManagedChannelImpl.java:351)
at io.grpc.internal.ManagedChannelImpl$ChannelTransportProvider$1ExitIdleModeForTransport.run(ManagedChannelImpl.java:447)
at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:101)
at io.grpc.SynchronizationContext.execute(SynchronizationContext.java:130)
at io.grpc.internal.ManagedChannelImpl$ChannelTransportProvider.get(ManagedChannelImpl.java:451)
at io.grpc.internal.ClientCallImpl.start(ClientCallImpl.java:241)
at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1.start(CensusTracingModule.java:392)
at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1.start(CensusStatsModule.java:689)
at io.grpc.ForwardingClientCall.start(ForwardingClientCall.java:32)
at com.google.api.gax.grpc.GrpcHeaderInterceptor$1.start(GrpcHeaderInterceptor.java:95)
at io.grpc.stub.ClientCalls.startCall(ClientCalls.java:308)
at io.grpc.stub.ClientCalls.asyncUnaryRequestCall(ClientCalls.java:280)
at io.grpc.stub.ClientCalls.futureUnaryCall(ClientCalls.java:189)
at com.google.api.gax.grpc.GrpcDirectCallable.futureCall(GrpcDirectCallable.java:58)
at com.google.api.gax.grpc.GrpcExceptionCallable.futureCall(GrpcExceptionCallable.java:64)
at com.google.api.gax.rpc.AttemptCallable.call(AttemptCallable.java:86)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:63)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:41)
at com.google.api.gax.tracing.TracedUnaryCallable.futureCall(TracedUnaryCallable.java:75)
at com.google.api.gax.rpc.UnaryCallable$1.futureCall(UnaryCallable.java:126)
at com.google.api.gax.rpc.UnaryCallable.futureCall(UnaryCallable.java:87)
at com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112)
at com.google.cloud.pubsub.v1.SubscriptionAdminClient.getSubscription(SubscriptionAdminClient.java:467)
at com.google.cloud.pubsub.v1.SubscriptionAdminClient.getSubscription(SubscriptionAdminClient.java:420)
at my.package.MyClass.start(MyClass.java:37)
at my.package.App$1.run(App.java:31)
at java.base/java.lang.Thread.run(Thread.java:834)
External references such as API reference guides used
- None
Any additional information below
The error only occurs since google-cloud-pubsub 1.62.0 .
When using google-cloud-pubsub 1.61.0 or below, the error does not occur with the same user code.
Reacted by Adam Hurwitz, Xiongmin LIN, Evgenii Tsvigun, Thomas Young and Yusuf Dönmez
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Activity
kolea2 commentedon Mar 19, 2019
Thank you for the report!
@sduskis, @andreamlin, Pub/Sub version 1.62 included an upgrade in gax - any idea if there were changes that could have caused this?
sduskis commentedon Mar 19, 2019
@kolea2, can you tell if there was a grpc upgrade? That might be one possible reason.
kolea2 commentedon Mar 19, 2019
Yep - looks like grpc went from 1.17.1 to 1.18.0: #4496
ajaaym commentedon Mar 20, 2019
@sceee can you please share your docker file with full repro? I tried the steps you mentioned and couldn't reproduce.
olavloite commentedon Mar 20, 2019
@sceee I can reproduce this when I build a 'thick' jar using the maven shade plugin and add the Google Cloud client libraries as dependencies in the jar. Are you doing something like that?
If so, the files io.grpc.LoadBalancerProvider and io.grpc.NameResolverProvider from grpc-core/META-INF/services are probably not included in you final jar and this exception will occur.
A work-around is to add these files to your own jar by adding them either manually or by including them in your build process. The files should be in the META-INF/services/ folder of your jar.
If you add the files to your own project, you can include them in your final jar by using a maven-shade-plugin resource transformer like this:
sceee commentedon Mar 20, 2019
Thank you for your response guys. @olavloite indeed I am shading using gradle with
com.github.jengelman.gradle.plugins:shadow:5.0.0Is this an issue that will be fixed in the future in grpc or the google-java library or do I permanently need this workaround from now on?
And with the workaround, do you mean including these files in my own project and including in them in the final jar?
olavloite commentedon Mar 20, 2019
@sceee Yes, you should include those files in the META-INF/services directory of your jar, which means that you need to add them to your own project (at least for now as a workaround).
I'll have to discuss with someone else on what could be a possible long-term solution for this. @sduskis Could you point me in a direction of someone who might be able to help with that?
19 remaining items
wyaeld commentedon Jul 21, 2019
@olavloite
When using kotlin gradle build, I've found that a little more tuning is desirable. The normal workaround of turning on the
com.github.johnrengelman.shadowplugin, which has similar function to the maven shade plugin has an issue.If you do the default config, below:
tasks.withType<ShadowJar> { mergeServiceFiles () }it will work, but can result in a lot of undesirable files also ending up in the output jar, I'm unsure why. I ended up with 70mb of gradle internals.
However if you do this
You get the solution without extra pollution.
Would it be possible to get docs updated to make it easier for people to know this? Its an awkward problem to track down the first time it happens.
blacar commentedon Jul 22, 2019
I have found similar error using 'com.google.cloud:google-cloud-pubsub:1.83.0'.
trying to pusblish a message in a topic:
olavloite commentedon Jul 22, 2019
@blacar The above issue is something else than the original issue. You seem to run into an issue where an executor that is used by your transport channel is rejecting any further tasks. If this is something reproducible, it would be better to open a new issue with a clear description on how to reproduce the issue.
bajabob commentedon Aug 16, 2019
@olavloite & @mikessoldier & @wyaeld
First off, thank you so much for this wonderful thread. I am having the exact same issue. Using
com.google.firebase:firebase-admin:6.9.0+ Shadow 5.1.0 for packaging Jars. Mike, your manual META-INF service additions remedied the problem for me. Brad, your gradle tasks for adding only the required service files did not work for me.I am specifically following the Firestore quickstart guide for Java Admin SDK: https://firebase.google.com/docs/firestore/quickstart
adam-hurwitz commentedon Dec 28, 2019
@mikessoldier, I've attempted your proposed solution from March, 28, 2019 and I am still seeing the error.
I'm seeing the error above when attempting to run a Jar in IntelliJ. It works on the machine it was written on, but when the project is pulled to a new machine the issue above is occurring.
Related StackOverflow post: How to fix “Could not find policy 'pick_first'” with Google TTS java client?.
adam-hurwitz commentedon Dec 28, 2019
@olavloite, Where in the project should the ServiceFileTransformer be placed for a Gradle based project in order to resolve the error above?
adam-hurwitz commentedon Dec 28, 2019
@sceee, I've implemented the Gradle library
com.github.jengelman.gradle.plugins:shadow:5.0.0, but unfortunately the error above is still persisting.wyaeld commentedon Dec 29, 2019
@AdamSHurwitz I know it's a long thread, try my solution here #4700 (comment)
adam-hurwitz commentedon Dec 30, 2019
Thanks @wyaeld! My issues seems to be potentially unrelated now, as I'm seeing a new error when migrating projects from an existing MacBook Pro to a newer MacBook Pro.
StackOverflow: Kotlin Jar Error: Exception in thread “Timer-0” StorageException: 401 Unauthorized
rohith28 commentedon Oct 14, 2020
I am getting the same issues after updating the PubSub emulator component. I am reading pubsub data from Dataflow job.
Current gcloud componenets versions:
Emulator working fine with these components version
Error from emulator
Naidile-P-N commentedon Jul 14, 2023
I'm getting similar error while connecting to Bigtable from GKE.
Tried adding the files into META-INF/servcies of my project & modifying transformer in maven-shade-plugin and issue still persists.
I logged into the k8s pod and extracted my application jar and found that below files are present.
io.grpc.LoadBalancerProvider
io.grpc.NameResolverProvider
io.grpc.internal.DnsNameResolverProviderI'm using Kotlin with kotlin-maven-plugin & maven-shade-plugin
Internally BigTable is using Maven: io.grpc:grpc-core:1.55.1.
Tried a lot of workaround with no luck. Any help here please !
Caused by: java.lang.IllegalStateException: Default config is invalid: Status{code=UNKNOWN, description=None of [grpclb] specified by Service Config are available., cause=null} at com.google.common.base.Preconditions.checkState(Preconditions.java:590) at io.grpc.internal.ManagedChannelImpl.<init>(ManagedChannelImpl.java:642) at io.grpc.internal.ManagedChannelImplBuilder.build(ManagedChannelImplBuilder.java:631) at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:297) at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:391) at com.google.api.gax.grpc.ChannelPool.<init>(ChannelPool.java:107) at com.google.api.gax.grpc.ChannelPool.create(ChannelPool.java:85) at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:237) at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:231) at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:201) at com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStub.create(EnhancedBigtableStub.java:175) at com.google.cloud.bigtable.data.v2.BigtableDataClient.create(BigtableDataClient.java:165) at external_service.db.BigTableClientService$Companion.getBigTableClient(BigTableClientService.kt:18)Naidile-P-N commentedon Jul 15, 2023
I finally resolved the error by modifying the files as below and enabling
attemptDirectPathXdsduring Bigtable client creation.io.grpc.LoadBalancerProvider
io.grpc.NameResolverProvider
nitinvagal commentedon Jan 25, 2024
I was facing the same issue with cloud logging. Building the uber jar in following manner resolved it.
shubha95m commentedon Oct 3, 2024
Hello, I've tried everything which is suggested here, but no luck for me.
Can someone please help me here.
Thanks.