YourKit warns about a potential deadlock in Log4j2's AsyncAppenderEventDispatcher
:
Potential deadlock: frozen threads found
It seems that the following threads have not changed their stack for more than 10 seconds.
These threads are possibly (but not necessarily!) in a deadlock or hung.
--------------------------------------------------------------------------------------------------------------------------------
| Name |
--------------------------------------------------------------------------------------------------------------------------------
| ---Log4j2-AsyncAppenderEventDispatcher-2-Async Frozen for at least 9m 2s <Ignore a false positive> |
| | |
| ---jdk.internal.misc.Unsafe.park(boolean, long) Unsafe.java (native) |
| | |
| ---java.util.concurrent.locks.LockSupport.park(Object) LockSupport.java:194 |
| | |
| ---java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await() AbstractQueuedSynchronizer.java:2081 |
| | |
| ---java.util.concurrent.ArrayBlockingQueue.take() ArrayBlockingQueue.java:417 |
| | |
| ---org.apache.logging.log4j.core.appender.AsyncAppenderEventDispatcher.dispatchAll() AsyncAppenderEventDispatcher.java:71 |
| | |
| ---org.apache.logging.log4j.core.appender.AsyncAppenderEventDispatcher.run() AsyncAppenderEventDispatcher.java:63 |
--------------------------------------------------------------------------------------------------------------------------------
Log4j2's config (simplified):
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" packages="com.mycompany.logging">
<Appenders>
<RollingFile name="RollingJson"
fileName="logs/application.log.json" filePattern="logs/application.log.json.%i"
bufferedIO="true" bufferSize="1024">
<MyCompanyJsonLayout/>
<Policies>
<SizeBasedTriggeringPolicy size="1MB"/>
</Policies>
<DefaultRolloverStrategy max="100"/>
</RollingFile>
<Async name="Async">
<AppenderRef ref="RollingJson"/>
</Async>
</Appenders>
<Loggers>
<Root level="${env:LOG_LEVEL:-INFO}">
<AppenderRef ref="Async"/>
</Root>
</Loggers>
</Configuration>
Not sure how to investigate further, is this warning a false positive?
CodePudding user response:
This is a false positive. Since you are using the Async
appender, you have an instance of the AsyncAppenderEventDispatcher
thread that is waiting for other threads to fill the log message queue.
That is perfectly normal if there are no messages to be logged.