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 Activation code (e.g. reading 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:39,636 INFO [stdout] (ForkJoinPool-1-worker-16) Thread[#18608,ForkJoinPool-1-worker-16,5,CarrierThreads] 2024-07-18 05:23:39,636 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.lang.VirtualThread$VThreadContinuation.onPinned(VirtualThread.java:185) 2024-07-18 05:23:39,636 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/jdk.internal.vm.Continuation.onPinned0(Continuation.java:393) 2024-07-18 05:23:39,636 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.lang.VirtualThread.park(VirtualThread.java:592) 2024-07-18 05:23:39,636 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.lang.System$2.parkVirtualThread(System.java:2639) 2024-07-18 05:23:39,636 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/jdk.internal.misc.VirtualThreads.park(VirtualThreads.java:54) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.util.concurrent.locks.LockSupport.park(LockSupport.java:369) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.ch.Poller.pollIndirect(Poller.java:139) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.ch.Poller.poll(Poller.java:102) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.ch.Poller.poll(Poller.java:87) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.ch.NioSocketImpl.park(NioSocketImpl.java:175) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.ch.NioSocketImpl.park(NioSocketImpl.java:201) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:309) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:346) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:796) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.net.Socket$SocketInputStream.read(Socket.java:1099) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.util.TraceInputStream.read(TraceInputStream.java:107) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:329) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:372) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.cs.StreamDecoder.lockedRead(StreamDecoder.java:215) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:169) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.io.InputStreamReader.read(InputStreamReader.java:188) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.io.BufferedReader.fill(BufferedReader.java:160) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.io.BufferedReader.implReadLine(BufferedReader.java:370) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.io.BufferedReader.readLine(BufferedReader.java:347) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) java.base/java.io.BufferedReader.readLine(BufferedReader.java:436) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.pop3.Protocol.readResponse(Protocol.java:1211) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.pop3.Protocol.retr(Protocol.java:922) <== monitors:1 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.pop3.POP3Message.getRawStream(POP3Message.java:167) <== monitors:1 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.pop3.POP3Message.getContentStream(POP3Message.java:263) <== monitors:1 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.pop3.POP3Message.loadHeaders(POP3Message.java:644) <== monitors:1 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) org.eclipse.angus.mail@2.0.3//org.eclipse.angus.mail.pop3.POP3Message.getHeader(POP3Message.java:379) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) jakarta.mail.api@2.1.3//jakarta.mail.internet.MimeMessage.getContentType(MimeMessage.java:1025) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) jakarta.mail.api@2.1.3//jakarta.mail.internet.MimePartDataSource.getContentType(MimePartDataSource.java:120) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) jakarta.activation.api@2.1.3//jakarta.activation.DataHandler.getContentType(DataHandler.java:179) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) jakarta.activation.api@2.1.3//jakarta.activation.DataHandler.getBaseType(DataHandler.java:614) <== monitors:1 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) jakarta.activation.api@2.1.3//jakarta.activation.DataHandler.getDataContentHandler(DataHandler.java:577) <== monitors:1 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) jakarta.activation.api@2.1.3//jakarta.activation.DataHandler.getContent(DataHandler.java:515) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) jakarta.mail.api@2.1.3//jakarta.mail.internet.MimeMessage.getContent(MimeMessage.java:1504) 2024-07-18 05:23:39,637 INFO [stdout] (ForkJoinPool-1-worker-16) deployment.d1e69a0b-f63d-4d5f-aa9a-5f42cf984c53.war//org.jboss.as.test.integration.mail.basic.MailTesterServlet.tryToReadEmails(MailTesterServlet.java:84)
Note that this stack trace also shows pinning in Angus. That 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
- is related to
-
WFLY-19714 Resolve virtual thread pinning issues in client side Jakarta Mail code
- Open
- relates to
-
WFLY-19711 Resolve virtual thread pinning issues in client side Angus code
- Open