ZOOKEEPER-2893. very poor choice of logging if client fails to connect to server #430
Conversation
…e to give a chance to fallback if the socket hasn't been initialized yet
LOG.warn( | ||
"Session 0x" | ||
+ Long.toHexString(getSessionId()) | ||
+ " for server " | ||
+ clientCnxnSocket.getRemoteSocketAddress() | ||
+ (remoteAddr == null ? addr : remoteAddr) |
paulmillar
Dec 13, 2017
I believe that, if clientCnxnSocket.getRemoteSocketAddress()
is non-null, the value is always the same as addr
.
If so, then this could be simplified to just addr
without the ternary operation.
I believe that, if clientCnxnSocket.getRemoteSocketAddress()
is non-null, the value is always the same as addr
.
If so, then this could be simplified to just addr
without the ternary operation.
paulmillar
Dec 13, 2017
Of course this comment is [non-blocking]
Of course this comment is [non-blocking]
anmolnar
Dec 13, 2017
Author
Contributor
Makes sense. I'll just use 'addr' here.
Makes sense. I'll just use 'addr' here.
@@ -1041,6 +1041,8 @@ private void sendPing() { | |||
|
|||
private InetSocketAddress rwServerAddress = null; | |||
|
|||
private InetSocketAddress addr = null; |
paulmillar
Dec 13, 2017
[non-blocking]
The name could be an ambiguous: is this the address of the local (client) side of the connection, or the remote (server) side of the connection? Especially as there is rwServerAddress
field member defined immediately above.
Suggest serverAddress
(or similar)
[non-blocking]
The name could be an ambiguous: is this the address of the local (client) side of the connection, or the remote (server) side of the connection? Especially as there is rwServerAddress
field member defined immediately above.
Suggest serverAddress
(or similar)
anmolnar
Dec 13, 2017
Author
Contributor
Remote side of the connection. Basically the ip address that the client is trying to connect to. rwServerAddress
is the address of non-R/O server found if there's any.
I'll change this to serverAddress
.
Remote side of the connection. Basically the ip address that the client is trying to connect to. rwServerAddress
is the address of non-R/O server found if there's any.
I'll change this to serverAddress
.
…og message, it's always populated with the correct remote endpoint
@@ -1236,7 +1237,7 @@ public void run() { | |||
"Session 0x" | |||
+ Long.toHexString(getSessionId()) | |||
+ " for server " | |||
+ clientCnxnSocket.getRemoteSocketAddress() | |||
+ serverAddress | |||
+ ", unexpected error" | |||
+ RETRY_CONN_MSG, e); |
phunt
Dec 14, 2017
Contributor
I think it would be good to address the other issue Paul mentioned - no need to dump a stack if we know this is NoRouteToHostException - why wouldn't we add another elseif to check for this type?
I think it would be good to address the other issue Paul mentioned - no need to dump a stack if we know this is NoRouteToHostException - why wouldn't we add another elseif to check for this type?
anmolnar
Dec 14, 2017
Author
Contributor
We're talking about the same thing in the Jira. It's arguable which exception should be logged at INFO level without the stack trace, I ended up separating SocketExceptions altogether and leaving the rest for the original handler.
We're talking about the same thing in the Jira. It's arguable which exception should be logged at INFO level without the stack trace, I ended up separating SocketExceptions altogether and leaving the rest for the original handler.
@@ -1041,6 +1041,8 @@ private void sendPing() { | |||
|
|||
private InetSocketAddress rwServerAddress = null; | |||
|
|||
private InetSocketAddress serverAddress = null; |
phunt
Dec 14, 2017
Contributor
This seems kinda bogus to me - why push this up to a field. Can't we determine the server address in "run" method, as a local variable, and call startConnect with that as an argument? That seems like an improvement to startConnect call at the same time. What do you think @anmolnar , does that make sense or am I missing something?
This seems kinda bogus to me - why push this up to a field. Can't we determine the server address in "run" method, as a local variable, and call startConnect with that as an argument? That seems like an improvement to startConnect call at the same time. What do you think @anmolnar , does that make sense or am I missing something?
anmolnar
Dec 14, 2017
Author
Contributor
Good idea. I've made the change.
Good idea. I've made the change.
…SocketExceptions from generic ex handler and log at info level.
+ clientCnxnSocket.getRemoteSocketAddress() | ||
+ ", unexpected error" | ||
+ RETRY_CONN_MSG, e); | ||
LOG.warn("Session 0x{} for server {}, unexpected error{}", |
paulmillar
Dec 15, 2017
[non-blocking]
Although this isn't a regression, you probably want a ": " here (and a space); e.g.,
"Session 0x{} for server {}, unexpected error: {}"
[non-blocking]
Although this isn't a regression, you probably want a ": " here (and a space); e.g.,
"Session 0x{} for server {}, unexpected error: {}"
anmolnar
Dec 15, 2017
Author
Contributor
No, because the RETRY_CONN_MSG should go right after it. (starts with ", ")
No, because the RETRY_CONN_MSG should go right after it. (starts with ", ")
@paulmillar Please approve it, if you're happy with the change. |
…t to server '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. Author: Andor Molnar <andor@cloudera.com> Reviewers: phunt@apache.org Closes #430 from anmolnar/ZOOKEEPER-2893 and squashes the following commits: aa73554 [Andor Molnar] ZOOKEEPER-2893. Use log4j message templates 47a8cf4 [Andor Molnar] ZOOKEEPER-2893. Make serverAddress local variable of run(). Separate SocketExceptions from generic ex handler and log at info level. 6ea4cb2 [Andor Molnar] ZOOKEEPER-2893. Renamed addr to serverAddress, use serverAddress in log message, it's always populated with the correct remote endpoint fbe4ccd [Andor Molnar] ZOOKEEPER-2893. Make 'addr' variable available for error handling code to give a chance to fallback if the socket hasn't been initialized yet Change-Id: I22becf9c1f923a28c82f263b604239fde9bc0ce4 (cherry picked from commit e129e7a) Signed-off-by: Patrick Hunt <phunt@apache.org>
…t to server '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. Author: Andor Molnar <andor@cloudera.com> Reviewers: phunt@apache.org Closes #430 from anmolnar/ZOOKEEPER-2893 and squashes the following commits: aa73554 [Andor Molnar] ZOOKEEPER-2893. Use log4j message templates 47a8cf4 [Andor Molnar] ZOOKEEPER-2893. Make serverAddress local variable of run(). Separate SocketExceptions from generic ex handler and log at info level. 6ea4cb2 [Andor Molnar] ZOOKEEPER-2893. Renamed addr to serverAddress, use serverAddress in log message, it's always populated with the correct remote endpoint fbe4ccd [Andor Molnar] ZOOKEEPER-2893. Make 'addr' variable available for error handling code to give a chance to fallback if the socket hasn't been initialized yet Change-Id: I22becf9c1f923a28c82f263b604239fde9bc0ce4 (cherry picked from commit e129e7a)
…t to server '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. Author: Andor Molnar <andor@cloudera.com> Reviewers: phunt@apache.org Closes apache#430 from anmolnar/ZOOKEEPER-2893 and squashes the following commits: aa73554 [Andor Molnar] ZOOKEEPER-2893. Use log4j message templates 47a8cf4 [Andor Molnar] ZOOKEEPER-2893. Make serverAddress local variable of run(). Separate SocketExceptions from generic ex handler and log at info level. 6ea4cb2 [Andor Molnar] ZOOKEEPER-2893. Renamed addr to serverAddress, use serverAddress in log message, it's always populated with the correct remote endpoint fbe4ccd [Andor Molnar] ZOOKEEPER-2893. Make 'addr' variable available for error handling code to give a chance to fallback if the socket hasn't been initialized yet Change-Id: I22becf9c1f923a28c82f263b604239fde9bc0ce4
'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.