Skip to content

Issue with virtual-threads #10181

@vmaleze

Description

@vmaleze

Describe the bug

The java-agent locks any application using virtual-threads upon an external call if you add the -Djdk.tracePinnedThreads=short to the VM options.

Steps to reproduce

Create a fresh application using either spring or micronaut.
Enable virtual-threads and add -Djdk.tracePinnedThreads=short to the VM options
Add an external call to a BDD done through a rest controller. (Im guessing that any external call will do that, but I only have a redis or a mysql db to test)

Expected behavior

The application should not lock itself by adding -Djdk.tracePinnedThreads=short to the VM options

Actual behavior

The http call is stuck forever and the application is also stuck with no other way than to restart it.

Javaagent or library instrumentation version

1.32.0

Environment

JDK: 21
OS: Ubuntu 22.04 / MacOs 14.2.1
Spring Boot: 3.2.1 / ** Micronaut**: 4.2.3

Additional context

I have a fresh micronaut application (version 4.2.3) that runs on java 21 with virtual-threads enabled.
This application also uses the opentelemetry java agent (version 1.32.0)

To debug pinned threads, I added -Djdk.tracePinnedThreads=short . This works fine on a vanilla application with a hello-world controller.
However upon adding a call to an external sytem, the application locks itself in a state where it does not respond anymore.
I tried calling a redis cache or a mysql database, but the results ends-up being the same.
This also happens on a spring application.

If I remove the java-agent, or disable virtual-threads, I don't have any problem.

I first noticed this on another application that I migrated towards java 21. Upon stress test, the service ended up being stucked. I suspected virtual-threads so I wanted to monitor pinned threads. And upon adding the jvm param. The application locks itself on the first call.
I am unable to find the actual root cause. But it seems to be coming from the java-agent upon calling an external resource. If the jvm param is not added, the call succeed. But it will fails over time during stress tests. However, this is hard to reproduce if you just do stress tests as it can happen after 5 or 6 minutes whereas with this VM option, it fails right away

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions