logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Goers (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4J2-1012) AsyncAppender hang on shutdown if delegate Appender hangs
Date Tue, 12 May 2015 02:05:00 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1012?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14539091#comment-14539091
] 

Ralph Goers edited comment on LOG4J2-1012 at 5/12/15 2:04 AM:
--------------------------------------------------------------

I'd like to understand better why the Appender thread is not shutting down properly. I think
adding a timeout to join is solving the wrong problem. Exiting without waiting for the thread
to shut down  is bound to just cause other problems.


was (Author: ralph.goers@dslextreme.com):
I'd like to understand better why the Appender thread is not shutting down properly. I think
adding a timeout to join is solving the wrong problem.

> AsyncAppender hang on shutdown if delegate Appender hangs
> ---------------------------------------------------------
>
>                 Key: LOG4J2-1012
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1012
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.2
>            Reporter: Mikael Ståldal
>
> I have a custom appender which sometimes hangs forever on Appender.append(LogEvent).
To make sure that this does not affect my application, I have wrapped it with a non-blocking
AsyncAppender like this. (I rather lose some log events than lock-up my application).
> {code:xml}
> <Configuration status="WARN">
>     <Appenders>
>         <Custom name="Custom">
>         </Custom>
>         <Async name="AsyncCustom" blocking="false">
>             <AppenderRef ref="Custom"/>
>         </Async>
>     </Appenders>
>     <Loggers>
>         <Root level="INFO">
>             <AppenderRef ref="AsyncCustom"/>
>         </Root>
>     </Loggers>
> </Configuration>
> {code}
> This works fine as long as the application runs, but when I shut down, it can hang forever,
from jstack:
> {code}
> "pool-1-thread-1" prio=10 tid=0x00007f3e840cd800 nid=0x3945 in Object.wait() [0x00007f3e765de000]
>    java.lang.Thread.State: WAITING (on object monitor)
> 	at java.lang.Object.wait(Native Method)
> 	- waiting on <0x00000007490d2b88> (a org.apache.logging.log4j.core.appender.AsyncAppender$AsyncThread)
> 	at java.lang.Thread.join(Thread.java:1281)
> 	- locked <0x00000007490d2b88> (a org.apache.logging.log4j.core.appender.AsyncAppender$AsyncThread)
> 	at java.lang.Thread.join(Thread.java:1355)
> 	at org.apache.logging.log4j.core.appender.AsyncAppender.stop(AsyncAppender.java:119)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.stop(AbstractConfiguration.java:228)
> 	at org.apache.logging.log4j.core.LoggerContext.stop(LoggerContext.java:224)
> 	at org.apache.logging.log4j.core.LoggerContext$1.run(LoggerContext.java:185)
> 	at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry$1.run(DefaultShutdownCallbackRegistry.java:101)
> 	at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.run(DefaultShutdownCallbackRegistry.java:75)
> 	at java.lang.Thread.run(Thread.java:745)
>    Locked ownable synchronizers:
> 	- <0x00000007490e9360> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
> "AsyncAppender-AsyncCustom" daemon prio=10 tid=0x00007f3e84676000 nid=0x386b waiting
on condition [0x00007f3e77df6000]
> [...hang in CustomAppender...]
> org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:99)
> 	at org.apache.logging.log4j.core.appender.AsyncAppender$AsyncThread.callAppenders(AsyncAppender.java:290)
> 	at org.apache.logging.log4j.core.appender.AsyncAppender$AsyncThread.run(AsyncAppender.java:241)
>    Locked ownable synchronizers:
> 	- None
> {code}
> It would be nice if AsyncAppender could fully protect you from faulty appenders and have
some timeout on shutdown (at least when you specify blocking=false). Proper shutdown of the
application is important for me.
> (I know that I should fix my faulty custom appender, but I want an extra safety net to
make my application reliable and robust.)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message