quarkus: Error using Redis client inside gRPC server thread
Describe the bug When using redisClient.get() from a gRPC server thread the call gets fails with a vertx thread blocked error.
Expected behavior The call should return.
Actual behavior The call fails with thread blocked error.
To Reproduce Reproduceable with the grpc-plain-text-quickstart quarkus sample project and quarkus-redis-client extension.
Steps to reproduce the behavior:
- Download grpc-plain-text-quickstart sample project
- In HelloWorldService inject RedisClient and in sayHello method add redisClient.get(“xxx”);
- mvnw quarkus:dev
- From browser navigate to http://localhost:XXXX/hello/blocking/Test or http://localhost:XXXX/hello/mutiny/Test
- In the terminal there are some exceptions shown (see screenshots)
Configuration
Add your application.properties here, if applicable.
sample project properties file
Screenshots 2020-10-10 12:41:32,780 INFO [io.quarkus] (Quarkus Main Thread) grpc-redis 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.8.1.Final) started in 1.342s. Listening on: http://0.0.0.0:9090 2020-10-10 12:41:32,781 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. 2020-10-10 12:41:32,782 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, grpc-client, grpc-server, mutiny, redis-client, resteasy, resteasy-mutiny, smallrye-context-propagation, vertx ] 2020-10-10 12:41:32,782 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (vert.x-worker-thread-1) Hot replace total time: 3.058s 2020-10-10 12:41:35,549 WARNING [io.ver.cor.imp.BlockedThreadChecker] (vertx-blocked-thread-checker) Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been bl ocked for 2465 ms, time limit is 2000 ms: io.vertx.core.VertxException: Thread blocked at java.base@11.0.5/jdk.internal.misc.Unsafe.park(Native Method) at java.base@11.0.5/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234) at java.base@11.0.5/java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1079) at java.base@11.0.5/java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1369) at java.base@11.0.5/java.util.concurrent.CountDownLatch.await(CountDownLatch.java:278) at io.smallrye.mutiny.operators.UniBlockingAwait.await(UniBlockingAwait.java:51) at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:61) at io.quarkus.redis.client.runtime.RedisClientImpl.await(RedisClientImpl.java:1026) at io.quarkus.redis.client.runtime.RedisClientImpl.get(RedisClientImpl.java:237) at io.quarkus.redis.client.runtime.RedisAPIProducer_ProducerField_redisClient_ClientProxy.get(RedisAPIProducer_ProducerField_redisClient_ClientProxy.zig:1495) at io.quarkus.grpc.examples.hello.HelloWorldService.sayHello(HelloWorldService.java:24) at examples.MutinyGreeterGrpc$MethodHandlers$$Lambda$737/0x00000001005f7040.apply(Unknown Source) at io.quarkus.grpc.runtime.ServerCalls.oneToOne(ServerCalls.java:22) at examples.MutinyGreeterGrpc$MethodHandlers.invoke(MutinyGreeterGrpc.java:104) at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:172) at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:331) at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:820) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) at io.quarkus.grpc.runtime.GrpcServerRecorder.lambda$null$2(GrpcServerRecorder.java:294) at io.quarkus.grpc.runtime.GrpcServerRecorder$$Lambda$736/0x00000001005f7c40.handle(Unknown Source) at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:327) at io.vertx.core.impl.ContextImpl$$Lambda$514/0x0000000100480440.handle(Unknown Source) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366) at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) at io.vertx.core.impl.EventLoopContext$$Lambda$510/0x00000001003e9c40.run(Unknown Source) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base@11.0.5/java.lang.Thread.run(Thread.java:834)
Environment (please complete the following information):
- Output of
uname -a
orver
: - Output of
java -version
: openjdk version “11.0.5” 2019-10-15 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode) - GraalVM version (if different from Java): Not relevant
- Quarkus version or git rev: 1.8.1.Final
- Build tool (ie. output of
mvnw --version
orgradlew --version
): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\Users\xxxxx.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3 Java version: 11.0.5, vendor: AdoptOpenJDK, runtime: C:\Program Files\AdoptOpenJDK\jdk-11.0.5.10-hotspot Default locale: en_US, platform encoding: Cp1252 OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows” Additional context
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (9 by maintainers)
As I said, we will provide blocking ability, but gRPC is designed to be non-blocking and async (not our implementation, gRPC itself).
Let me propose a second approach a bit easier maybe. You still return a
Uni
but you do it in a synchronous manner: