quarkus: Deadlock using Caffeine cache and context propagation
Describe the bug When using quarkus-cache together with quarkus-smallrye-context-propagation extension, a method annotated with @CacheResult deadlocks with 200 or more concurrent calls
Expected behavior No deadlock
Actual behavior
When using a tool like jMeter to submit 200 or more simultaneos calls, all threads immediately deadlocks on a method annotated with @CacheResult
Removing the extension quarkus-smallrye-context-propagation, the issue doesn’t occur anymore
To Reproduce
I created an example project to reproduce this issue: https://github.com/sivelli/quarkus-cache-deadlock But the code is really simple:
@ApplicationScoped
class ExampleCache {
@CacheResult(cacheName = "test")
public Integer getLength(String param) {
return param.length();
}
}
@Path("/resteasy/hello")
public class ExampleResource {
@Inject
ExampleCache cache;
AtomicInteger counter = new AtomicInteger();
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello(@QueryParam("name") String name) {
System.out.println("request received " + counter.incrementAndGet());
return "hello " + name + " Length:" + cache.getLength(Objects.toString(name, ""));
}
}
In pom.xml, if the following dependency is present, the problem happens when making 200 calls simultaneosly
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-context-propagation</artifactId>
</dependency>
Removing this dependency, no deadlock happens
Steps to reproduce the behavior:
- Start the application
- Submit 200 or more simultaneous requests (run testCache.jmx)
Environment:
- Output of
uname -aorver: Microsoft Windows [versão 10.0.18363.657] - Output of
java -version: openjdk version “11.0.8” 2020-07-14 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode) - Quarkus version: 1.9.2.Final
- Output of
mvn -versionApache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: D:\Projetos\Java\apache-maven-3.6.3\bin.. Java version: 11.0.8, vendor: Red Hat, Inc., runtime: D:\Projetos\Java\jdk-11.0.8.10-2 Default locale: pt_BR, platform encoding: Cp1252 OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (17 by maintainers)
Thanks for that information @FroMage.
@ben-manes I updated the PR, I hope starvation is gone for good now! 😃 The extension code is much simpler now.