-
Feature Request
-
Resolution: Done
-
Minor
-
5.13.1.Final
-
None
Virtual threads do not play nice with synchronized blocks when the protected block executes network calls or other long running actions. This can lead to carrier thread pinning and deadlocks.
From the JEP (425):
Instead, avoid frequent and long-lived pinning by revising synchronized blocks or methods that run frequently and guard potentially long I/O operations to use java.util.concurrent.locks.ReentrantLock instead.
This limitation is here to stay for the forseeable future, so many JDBC vendors including Oracle have already made the changes to their JDBC drivers, and many are doing it now, e.g. postgres: https://github.com/pgjdbc/pgjdbc/pull/2635
I propose replacing the syncronized blocks in the transaction managers hot path that cause the thread pinnings in BasicAction and TwoPhaseCoordinator like in this patch: https://github.com/imperatorx/narayana/commit/346c843feda6c57433d448230a3eea6037feec87
to avoid carrier thread pinning.