You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Harper, Allen (AHARPER)" <AH...@arinc.com> on 2005/03/04 19:40:52 UTC

Appender, ErrorHanlder fail over deadlock

I have found and proved that Log4J does have a deadlock situation in
it's appender failover logic. 

In a nutshell heres whats happening. The entire instance of the logger
is syncronized. (Actually the syncronized object is the Category object
from which the Logger is derived.) A caller makes a log call
Log.xxxx(), in this case the JDBC appender. If the database is down the
DB call throws which in turn calls the errorHandler, which in turn calls
back into the Logger (deadlock) to swap out the primary and backup
appenders.

I guess what I'm going to do is to bust out another thread for the sole
purpose of handling failover logic.

Comments, input?

Al Harper


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


Re: Appender, ErrorHanlder fail over deadlock

Posted by Ceki Gülcü <ce...@qos.ch>.
Al,

I don't know what to do with your report since 1.3 the fail over logic is 
going to be entirely redesigned.

At 07:40 PM 3/4/2005, Harper, Allen (AHARPER) wrote:
>I have found and proved that Log4J does have a deadlock situation in
>it's appender failover logic.
>
>In a nutshell heres whats happening. The entire instance of the logger
>is syncronized. (Actually the syncronized object is the Category object
>from which the Logger is derived.) A caller makes a log call
>Log.xxxx(), in this case the JDBC appender. If the database is down the
>DB call throws which in turn calls the errorHandler, which in turn calls
>back into the Logger (deadlock) to swap out the primary and backup
>appenders.
>
>I guess what I'm going to do is to bust out another thread for the sole
>purpose of handling failover logic.
>
>Comments, input?
>
>Al Harper

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



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


Re: Appender, ErrorHanlder fail over deadlock

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Saturday 05 March 2005 02:40, Harper, Allen (AHARPER) wrote:

> In a nutshell heres whats happening. The entire instance of the logger
> is syncronized. (Actually the syncronized object is the Category object
> from which the Logger is derived.) A caller makes a log call
> Log.xxxx(), in this case the JDBC appender. If the database is down the
> DB call throws which in turn calls the errorHandler, which in turn calls
> back into the Logger (deadlock) to swap out the primary and backup
> appenders.


I am on the same line of thinking that Ceki... How can you say that a single 
thread makes a deadlock??

This will not block;

public class Test
{
    private int m_counter = 10;

    public void doSomething()
    {
        synchronized( this )
        {
           while( m_counter-- > 0 )
                doSomething();
        }
    }

    static public void main( String[] args )
    {
        Test t = new Test();
        t.doSomething();
    }
}

so another thread is involved somewhere in your case. 
Hitting Ctrl-Break (Windows) or Ctrl-\ (Linux) will give you a stack dump with 
the monitors acquired and waited upon.


Cheers
Niclas

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