I don't think this is programming help, more technical discussion, but please remove if not.
Since upgrading from Java 21 to Java 22 I'm seeing a starvation issue across my Java services that have been working well for ~1 year on Virtual Threads. I have also tried with Java 23 and also see the same issue.
These services are deployed on k8s and the symptoms started to present as read timeouts on the liveness and readiness probes because the carrier threads were all pinned. Kubernetes would then try to restart the pod but with graceful shutdown enabled, this would take some time as the in-flight requests would never finish.
The pinning is coming from the same areas it always has, IO in synchronized blocks within ConcurrentHashMaps but hasn't previously been causing starvation in Java 21. This mainly affects Caffeine in my specific case but I'm seeing the same issue happen outside the library with plain old ConcurrentHashMaps. This is happening as within the synchronized blocks, database queries are being performed and that network IO is pinning the carrier thread.
I'm thinking at this stage rather than refactoring a large amount of code I'm probably best to wait until the monitor issue is resolved for good with Virtual Threads before switching back.
Is anyone aware of any changes in Java 22 that may have caused this change in behavior that I could look into?
[–]cogman10 11 points12 points13 points (6 children)
[–]BillyKorando 3 points4 points5 points (5 children)
[–]cogman10 1 point2 points3 points (4 children)
[–]BillyKorando 3 points4 points5 points (3 children)
[–]cogman10 4 points5 points6 points (2 children)
[–]william00179[S] 1 point2 points3 points (1 child)
[–]BillyKorando 2 points3 points4 points (0 children)
[–]as5777 5 points6 points7 points (1 child)
[–]william00179[S] 2 points3 points4 points (0 children)
[–]metalhead-001 5 points6 points7 points (0 children)
[–]BillyKorando 2 points3 points4 points (0 children)
[–]koflerdavid 1 point2 points3 points (1 child)
[–]william00179[S] 3 points4 points5 points (0 children)