-
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
Quarkus Cache always executes or deadlocks on Kotlin coroutines #21592
Comments
/cc @evanchooly, @gwenneg |
Thanks for reporting this @kdubb. I called http://localhost:8080/hello/test1 with:
Here's the result in the Quarkus log:
@mkouba Do you know why an interceptor would be invoked by ArC twice with varying arguments when the intercepted method is a Kotlin coroutine? |
This is definitely part of the issue and we should take care of it |
Yes, this should be an easy fix. But first I'd like to understand why the intercepted method is invoked twice. |
I have no idea. But I can try to take a look at the reproducer... |
So it seems that I think that we can ignore synthetic static methods with interceptor bindings. On the other hand, I don't think that we ignore non-static synthetic methods with interceptor bindings. @manovotn WDYT? |
For the record - I assume that the only reason why we don't ignore the non-static synthetic methods is that we expect that a framework can add a synthetic method that needs to be intercepted. But I'm not really sure this is something that should be supported. |
You beat me to it. I was going to ask if this is something we want to support anyway. It might even be surprising that such method gets intercepted. Personally, I think we could ignore both cases but at least synthetic static methods can definitely be skipped. |
- related to quarkusio#21592 (cherry picked from commit a580f28)
Closing this in favor of #23746 |
Describe the bug
When using
@CacheResult
on a Kotlin coroutine method the method is either always called (i.e. nothing is cached) or the method deadlocks.No Caching
The following example method, the method is always called; no caching is done.
This appears to be because the
kotlin.coroutines.Continuation
completion parameter is included in the cache key.Deadlock
You can "fix" the inclusion of the completion parameter using the
@CacheKey
annotation. Unfortunately, this causes a deadlock.Adding the annotation to the original example, causes any call to the cached method to deadlock.
When calling the method the invocation happens twice, and the second time deadlocks waiting for the cached value to be fulfilled.
Expected behavior
Kotlin coroutine methods work the same way as synchronous or reactive methods.
Kotlin continuation parameters (
kotlin.coroutines.Continuation
) should always be excluded from the cache key with having to use the@CacheKey
annotation.Actual behavior
Either no caching happen or the thread deadlocks when calling a coroutine with the
@CacheResult
.How to Reproduce?
./mvnw quarkus:dev
.https://localhost:8080/hello/test1
with return a new timestamp when it should be cached indefinitely after the first invocation.https://localhost:8080/hello/test2
will deadlock the request (and apparently the CLI along with it).code-with-quarkus.zip
Output of
uname -a
orver
macOS 12
Output of
java -version
Java version "17" 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.4.2 & 2.5.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: