qos-ch / reload4j

reload4j is a drop-in replacement for log4j 1.2.17
Apache License 2.0
148 stars 22 forks source link

Process hangs when logging buffer overflow happens and Dispathcer thread has died #76

Open rohitnitk2004 opened 3 months ago

rohitnitk2004 commented 3 months ago

Async appender checks dispatcher thread liveness and then only adds to logging buffer.

However If the dispatcher thread dies just after this liveness check and logging buffer is already full ( in multi-threaded application with too much logging happening ) then this thread gets blocked forever ( refer 1st snapshot)

To make it worse; it keeps holding a lock on Rootlogger which makes other threads blocked as well ( refer 2nd snapshot )

image

image

ceki commented 3 months ago

Thank you for this report. What leads you to believe that the dispatcher thread has died?

rohitnitk2004 commented 3 months ago

took thread dump of running application and saw below as per snapshot. We have a uncaught exception handler which logs error.

in this cases; dispatcher thread is not yet "dead" and like other logging threads; it is stuck trying to get lock on root logger. However it reached here because of an uncaught exception and in absence of uncaught exception handler; it would have died and led to same problem for other logging threads.

image