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 "Ralph Goers (JIRA)" <ji...@apache.org> on 2013/04/20 08:01:19 UTC

[jira] [Resolved] (LOG4J2-205) Deadlock with SocketAppender

     [ https://issues.apache.org/jira/browse/LOG4J2-205?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers resolved LOG4J2-205.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0-beta5
         Assignee: Ralph Goers

Deadlock was fixed in revision 1470110. A new option, immediateFail, was added to allow the event to not wait for the socket reconnection.  Please verify and close.
                
> Deadlock with SocketAppender
> ----------------------------
>
>                 Key: LOG4J2-205
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-205
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.0-beta4
>            Reporter: Werner 
>            Assignee: Ralph Goers
>            Priority: Critical
>             Fix For: 2.0-beta5
>
>         Attachments: SocketAppenderTest.java
>
>
> We found a Deadlock in the SocketAppender (TCPSocketManager.java), when the reconnectionDelay is used.
> A JUnit-Testcase (testTcpAppenderDeadlock()) has been attached, which reproduced the deadlock.
> Description of the JUnit-Testcase:
> •	No SocketServer is startet
> •	We generate a SocketAppender with a reconnectionDelay= 10sec
> •	The SocketAppender acknowledges that no SocktServer is there, and start the timeout
> •	During reconnectionDelay the SocketServer started and something is logged 
> •	Now the user-thread (here the JUNIT-Thread) and the Reconnector-Thread are blocking each other forever
> An additional Issue occurs: 
> If no SocketServer is available at the start of the SocketAppender, each user-thread is blocked at every logging operation up to the defined reconnection-time!
> Recommended solution:
> TCPSocketManager.java
>     @Override
>     protected synchronized void write(final byte[] bytes, final int offset, final int length)  {
> //        if (socket == null) {
> //            if (connector != null) {
> //                connector.latch();
> //            }
> //            if (socket == null) {
> //                final String msg = "Error writing to " + getName() + " socket not available";
> //                throw new AppenderRuntimeException(msg);
> //            }
> //        }
>        if (socket == null) {
> 			if (connector != null) {
> 				return;
> 			} else {
> 				final String msg = "Error writing to " + getName()
> 						+ " socket not available";
> 				throw new AppenderRuntimeException(msg);
> 			}
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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