When I was testing executing WildFly workloads on a virtual thread, turning on JVM thread pinning logging (see WFLY-19536) revealed pinning happening in client-side Jakarta Mail code (e.g. sending emails). This issue is to trace working with the Jakarta Activation community to resolve these issues and get the fixed code into WildFly.
See occurrences of 'onPinned' in https://ci.wildfly.org/repository/download/WF_MainNightlyJobs_StandardLinuxJdk21/446569:id/testsuite/integration/basic/target/wildfly/standalone/log/server.log. Lines in the stack trace annotated with "<== monitor" show where a monitor lock was taken that results in pinning when blocking code executes.
An example:
2024-07-18 05:23:37,548 INFO [stdout] (ForkJoinPool-1-worker-11) Thread[#10259,ForkJoinPool-1-worker-11,5,CarrierThreads] 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/java.lang.VirtualThread$VThreadContinuation.onPinned(VirtualThread.java:185) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/jdk.internal.vm.Continuation.onPinned0(Continuation.java:393) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/java.lang.VirtualThread.park(VirtualThread.java:592) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/java.lang.System$2.parkVirtualThread(System.java:2639) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/jdk.internal.misc.VirtualThreads.park(VirtualThreads.java:54) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/java.util.concurrent.locks.LockSupport.park(LockSupport.java:369) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/sun.nio.ch.Poller.pollIndirect(Poller.java:139) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/sun.nio.ch.Poller.poll(Poller.java:102) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/sun.nio.ch.Poller.poll(Poller.java:89) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/sun.nio.ch.NioSocketImpl.park(NioSocketImpl.java:175) 2024-07-18 05:23:37,549 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/sun.nio.ch.NioSocketImpl.park(NioSocketImpl.java:201) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/java.net.Socket.connect(Socket.java:751) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) java.base/java.net.Socket.connect(Socket.java:686) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.util.SocketFetcher.createSocket(SocketFetcher.java:368) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.util.SocketFetcher.getSocket(SocketFetcher.java:243) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2193) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:729) <== monitors:1 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) jakarta.mail.api@2.1.3//jakarta.mail.Service.connect(Service.java:367) <== monitors:1 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) jakarta.mail.api@2.1.3//jakarta.mail.Service.connect(Service.java:225) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) jakarta.mail.api@2.1.3//jakarta.mail.Service.connect(Service.java:174) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) jakarta.mail.api@2.1.3//jakarta.mail.Transport.send0(Transport.java:232) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) jakarta.mail.api@2.1.3//jakarta.mail.Transport.send(Transport.java:102) 2024-07-18 05:23:37,550 INFO [stdout] (ForkJoinPool-1-worker-11) deployment.d1e69a0b-f63d-4d5f-aa9a-5f42cf984c53.war//org.jboss.as.test.integration.mail.basic.MailTesterServlet.doGet(MailTesterServlet.java:48)
Note that the above trace also shows pinning in Angus, which is the subject of a separate issue – WFLY-19711.
To reproduce build https://github.com/bstansberry/wildfly/tree/pinning_check on SE 21.
- blocks
-
WFLY-19563 Support use of virtual threads in the Jakarta Concurrency 3.1. implementation
- Open
- is incorporated by
-
WFLY-19564 Epic: Virtual Threads support in WildFly
- Open
- relates to
-
WFLY-19711 Resolve virtual thread pinning issues in client side Angus code
- Open
-
WFLY-19713 Resolve virtual thread pinning issues in client side Jakarta Activation code
- Open