Summary
Virtual threads (https://openjdk.org/jeps/444) support is GA in Java 21 . We should make any necessary improvements to the Java driver to allow our users to make use of these new features.
Who is the affected end user?
Any MongoDB Java driver applications using virtual threads in Java 21+.
How does this affect the end user?
Users can currently choose to use Future.cancel or ExecutorService.shutdownNow to attempt to cancel or shut down threads. With structured concurrency, any fork (including a transitive fork) can cause threads of all other forks still active to be interrupted. This means that forks should be responsive to interruption.
How likely is it that this problem or use case will occur?
As more users upgrade to Java 21, they may need us to handle interruptions differently.
If the problem does occur, what are the consequences and how severe are they?
If a socket operation is interrupted, it will be treated as a a network error. However, it should be treated as an InterruptedException. (JAVA-4646)
Additionally, it is possible to create a scenario in which all virtual threads are starved of carrier threads due to the fact that all available carrier threads are pinned by synchronized blocks. (JAVA-4642)
Is this issue urgent?
Java 21 was released in September 2023. It is an LTS release. While generally users are slow to upgrade production apps to the latest JDK, adoption if newer JDKs is accelerating and we expect users to try this feature out as soon as it's available. Also, many application servers (Helidon, Spring Boot, Weblogic, Quarkus) either already do or will soon be able to operate in a mode where all requests are handled on virtual threads, which means that anyone using those servers with MongoDB will easily be able to create applications which are executing Java driver code on those virtual threads.
Is this ticket required by a downstream team?
No
Is this ticket only for tests?
No.
Cast of Characters
Engineering Lead: jeff.yemin@mongodb.com
Product Owner: ashni.mehta@mongodb.com