-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gRPC Context lost when using @Blocking #14665
Comments
My dirty workaround is this:
Basically I manually use a managedExecutor and I forward the gRPC context to the thread. But the issue is that I have to do this for all the methods. 😞 The issue now is that my GrpcErrorInterceptor is bypassed 😭 |
Why didn't you use an interceptor directly? Wouldn't that work? |
That's the point, I'm using interceptors in my spring-boot project. And I would like to use them with Quarkus too. The issue is that the context is lost between the service interceptor (that reads and store the JWT) and the client interceptor (that add the JWT in the headers). When using @Blocking, the service interceptor is running in the IO thread and client interceptor is running in the worker thread. So the gRPC context is lost. I need worker thread because I have blocking calls (other than grpc). So in my opinion, |
Yes, but that's the other issue you referenced. We need to implement the Context Propagation SPI for gRPC. I didn't have the time so far. |
Ok, so it's not a bug, it's just a missing feature. Is this something you planned ? Is there any way I can help ? If you have already an implementation idea in mind, just tell it and I may be able to implement it. I can come on zulip if it's more convenient for you. |
So if I save the context before the |
Yes, I would start with what you mentioned, however, you would need to restore the original context too. I'm also wondering if we need an implementation of ThreadContextProvider that would do that for us. |
Can you guide me for this one ?
With this solution I won't be able to use |
Yes, I believe that's the only thing required. |
It turned out it was not only that. The ThreadContextProvider is not magically picked up. 😞 So I created two PRs (see above). One with the ThreadContextProvider (#14687) wrapper and one without (#14697). @cescoffier Let me know which one you think it's best and if I need to improve something. I will let #14687 in draft since I don't think I used the ThreadContextListener correctly. I saw that the resteasy implementation is rather complex. See SmallRyeContextPropagationProcessor But maybe it's the way to go |
Describe the bug
I use a grpc service with some interceptors. One of the goal of those interceptors is to forward the JWT token from the gRPC service to any client calls later in the code. For this is use the gRPC context. This works fine if I don't use the
@Blocking
annotation.As expected the
@Blocking
annotation makes my code run into a worker thread. But since I have other grpc calls in this code the JWT is null since the context was lost.I tried
@ActivateRequestContext
on my method but it seems that it's not compatible with@Blocking
(see #13358).This issue sounds similar to #13959 but there is no mention of blocking. And for me the context set in the interceptor works so I don't think if it's related.
Expected behavior
I can use the gRPC context in blocking method.
Actual behavior
Context is lost when using
@Blocking
To Reproduce
If it make sense I can try to create a small reproducer, but I cannot share my current code. Let me know.
Steps to reproduce the behavior:
@Blocking
Configuration
irrelevant
Screenshots
irrelevant
Environment (please complete the following information):
uname -a
orver
:Linux gaetan-desktop 5.4.0-64-generic #72-Ubuntu SMP Fri Jan 15 10:27:54 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
java -version
:1.11.0.Final
mvnw --version
orgradlew --version
):Additional context
none
The text was updated successfully, but these errors were encountered: