-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
VirtualThreadPool blocks all carrier threads #12651
Comments
Sorry but it's not clear what you are doing, and the logs do not report any indication of the thread name, so we can't really try to figure things out from them. Please have a read at this section: The important part is that the |
I produced a minimal example of this: https://github.com/CLandsberg/JettyBug/blob/master/src/main/java/Main.java The Helloworld example freezes after some time. The key for this is adding two ServerConnectors it seems |
Example output:
All requests timeout afterwards. |
@CLandsberg sorry but with virtual threads it is of extreme importance to know how many cores (and therefore carrier threads) you have, and whether you override or not the number of carriers via system property. If the number of carriers is the same (or less) than the number of selectors of all Your example will run differently on my machine with M cores than on your machine with N cores. |
I use default parameters without any system property or other configuration. What i fail to understand is how the starting of complete independent Virtual Threads (changing the Timeunit to seconds here) prevent the blocking of carrier threads. It might be coincidental, but this could also be a symptom of a major issue. |
@CLandsberg the behaviors are machine specific as @sbordet pointed out. For example, on my machine, your demo never hangs. (I changed the iteration to once every 5 seconds, just to see it operate. If I leave it at the original once every 1 minute, the behavior is the same, no hang, just less output)
|
@sbordet @joakime Does it make sense to you starting a virtual thread every second should prevents the blocking on my System while changing it to every minute blocks it right away? And doesn't the QueuedThreadPool also use the same number of virtual threads for selectors? I would expect them to behave the same. |
@CLandsberg it is not clear what you're trying to do. You do not want to configure virtual threads, but then have to add workarounds such as starting a virtual thread every second to avoid carrier pinning. Using Virtual threads have a number of surprises and gotchas, but we arranged to get the minimum surprises and still use them with the
For practically all purposes, |
Jetty version(s)
12.0.15 & 12.0.16
Jetty Environment
ee10
Java version/vendor
(use: java -version)
Corretto-23.0.1.8.1
OS type/version
Linux 6.12.4-arch1-1 x86_64
Description
I am unable to start any (!!) virtual thread after no virtual thread (ANY virtual thread -> no link to jetty) is used for ~ 30 seconds after using org.eclipse.jetty.util.thread.VirtualThreadPool.
Using
works fine. Using Java 24 EA works fine as well with VirtualThreadPool.
I inserted
as a Test in the first line of the application. The Problem is when using the VirtualThreadPool class:
The last block i get before this happens is
It looks like the virtual threads scheduled but never executed. The thread dump looks a bit like described here https://netflixtechblog.com/java-21-virtual-threads-dude-wheres-my-lock-3052540e231d but i do not see the threads waiting for any locks
The text was updated successfully, but these errors were encountered: