problem
- The springboot program was hang in virtual and debug mode
- But it was right in run mode.
- I think this is a bug and not a feature. It is right?
Reproduce
env
- Demo:https://github.com/walkertest/spring-boot-virtual-threads-experiment
- Springboot version: 3.2.1
- jdkVersion: jdk21
- virtualThreadMode: true
- Request: curl "127.0.0.1:8082/testFunc?func=syncSleep1"
- code env
private synchronized void syncSleep() {
System.out.println("test");
log.info("syncSleep start");
try {
Thread.sleep(Duration.ofSeconds(1));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
log.info("syncSleep end");
}
result
debug mode
run mode
Comment From: wilkinsona
Isn't this another variant of https://stackoverflow.com/questions/77779953/spring-boot-virtual-threads-djdk-tracepinnedthreads-full-causes-tasks-to-hang and https://github.com/spring-projects/spring-boot/issues/39112?
You're deliberately pinning a virtual thread and the thread is then hanging. This is out of Spring Boot's control as it's not involved with the scheduling of the virtual thread. That scheduling is performed by the JVM. That it only happens when debugging the application is a further indicator that it's a JVM problem.
Comment From: walkertest
Isn't this another variant of https://stackoverflow.com/questions/77779953/spring-boot-virtual-threads-djdk-tracepinnedthreads-full-causes-tasks-to-hang and #39112?
You're deliberately pinning a virtual thread and the thread is then hanging. This is out of Spring Boot's control as it's not involved with the scheduling of the virtual thread. That scheduling is performed by the JVM. That it only happens when debugging the application is a further indicator that it's a JVM problem.
Thanks, it maybe jdk bug. I see the problem here: https://github.com/openjdk/jdk/pull/17221
Comment From: wilkinsona
Thanks for sharing the link to the JDK issue.