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

ASF GitHub Bot commented on ZOOKEEPER-2893:
-------------------------------------------

GitHub user anmolnar opened a pull request:

    https://github.com/apache/zookeeper/pull/430

    ZOOKEEPER-2893. Make 'addr' variable available for error handling code to 
give a chance to fallback if the socket hasn't been initialized yet

    'addr' variable is used to identify which server to connect to.
    I've made this available for error handling code in order to let it 
fallback to this address if the remote socket hasn't been initialised yet. This 
will give us better error messages if the client is unable to connect to server 
for some reason.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/anmolnar/zookeeper ZOOKEEPER-2893

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/zookeeper/pull/430.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #430
    
----
commit fbe4ccde8516150cfd69d2a2260266fd1c0bf10d
Author: Andor Molnar <an...@cloudera.com>
Date:   2017-12-12T13:46:34Z

    ZOOKEEPER-2893. Make 'addr' variable available for error handling code to 
give a chance to fallback if the socket hasn't been initialized yet

----


> very poor choice of logging if client fails to connect to server
> ----------------------------------------------------------------
>
>                 Key: ZOOKEEPER-2893
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2893
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: java client
>    Affects Versions: 3.4.6
>            Reporter: Paul Millar
>            Assignee: Andor Molnar
>
> We are using ZooKeeper in our project and have received reports that, when 
> suffering a networking problem, log files become flooded with messages like:
> {quote}
> 07 Sep 2017 08:22:00 (System) [] Session 0x45d3151be3600a9 for server null, 
> unexpected error, closing socket connection and attempting reconnect
> java.net.NoRouteToHostException: No route to host
>         at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 
> ~[na:1.8.0_131]
>         at 
> sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) 
> ~[na:1.8.0_131]
>         at 
> org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
>  ~[zookeeper-3.4.6.jar:3.4.6-1569965]
>         at 
> org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081) 
> ~[zookeeper-3.4.6.jar:3.4.6-1569965]
> {quote}
> Looking at the code that logs this message ({{ClientCnxn}}), there seems to 
> be quite a few problems here:
> # the code logs a stack-trace, even though there is no bug here.  In our 
> project, we treat all logged stack-traces as bugs,
> # if the networking issue is not fixed promptly, the log files is flooded 
> with these message,
> # The message is built using {{ClientCnxnSocket#getRemoteSocketAddress}}, yet 
> in this case, this does not provide the expected information (yielding 
> {{null}}),
> # The log message fails to include a description of what actually went wrong.
> (Additionally, the code uses string concatenation rather than templating when 
> building the message; however, this is an optimisation issue)
> My suggestion is that this log entry is updated so that it doesn't log a 
> stack-trace, but does include some indication why the connection failed.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to