Hi all, I recently investigated a deadlock happening inside our JBoss AS. I tracked down the root cause to the AsyncAppender of log4j. We use it in blocking mode, with the default buffer size of 128. I was able to reproduce the deadlock live even when increasing the buffer size to 512.
The problem comes from a race condition when the dispatcher thread dies from an exception. When that happens, if the buffer has been filled up by other threads doing logging, the thread currently waiting on the buffer to be emptied will never be notified and wait there forever. As a category lock is held to access the appender, this lead other threads to block forever. I found a bug in the database: https://issues.apache.org/bugzilla/show_bug.cgi?id=45915 However, the root cause was associated to logging from the Dispatcher thread. I have attached a test cause causing the deadlock, showing it can occur even when not logging from the dispatcher thread. Should I reopen that bug or create a new one? We are using log4j 1.2.14 and JBoss AS 4.3.0. The latest trunk version of AsyncAppender still suffers from the race condition. Regards, Louis
Log4JAsyncAppenderDeadLock.java
Description: Binary data
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
