New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZOOKEEPER-2893. very poor choice of logging if client fails to connect to server #430

Closed
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@anmolnar
Contributor

anmolnar commented Dec 12, 2017

'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.

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

@anmolnar anmolnar changed the title from ZOOKEEPER-2893. Make 'addr' variable available for error handling code to give a chance to fallback if the socket hasn't been initialized yet to ZOOKEEPER-2893. very poor choice of logging if client fails to connect to server Dec 12, 2017

LOG.warn(
"Session 0x"
+ Long.toHexString(getSessionId())
+ " for server "
+ clientCnxnSocket.getRemoteSocketAddress()
+ (remoteAddr == null ? addr : remoteAddr)

This comment has been minimized.

@paulmillar

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.

This comment has been minimized.

@paulmillar

paulmillar Dec 13, 2017

Of course this comment is [non-blocking]

This comment has been minimized.

@anmolnar

anmolnar Dec 13, 2017

Contributor

Makes sense. I'll just use 'addr' here.

@@ -1041,6 +1041,8 @@ private void sendPing() {
private InetSocketAddress rwServerAddress = null;
private InetSocketAddress addr = null;

This comment has been minimized.

@paulmillar

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)

This comment has been minimized.

@anmolnar

anmolnar Dec 13, 2017

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.

ZOOKEEPER-2893. Renamed addr to serverAddress, use serverAddress in l…
…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);

This comment has been minimized.

@phunt

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?

This comment has been minimized.

@anmolnar

anmolnar Dec 14, 2017

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.

@@ -1041,6 +1041,8 @@ private void sendPing() {
private InetSocketAddress rwServerAddress = null;
private InetSocketAddress serverAddress = null;

This comment has been minimized.

@phunt

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 comment has been minimized.

@anmolnar

anmolnar Dec 14, 2017

Contributor

Good idea. I've made the change.

ZOOKEEPER-2893. Make serverAddress local variable of run(). Separate …
…SocketExceptions from generic ex handler and log at info level.

@anmolnar anmolnar force-pushed the anmolnar:ZOOKEEPER-2893 branch from 84ed736 to 47a8cf4 Dec 14, 2017

+ clientCnxnSocket.getRemoteSocketAddress()
+ ", unexpected error"
+ RETRY_CONN_MSG, e);
LOG.warn("Session 0x{} for server {}, unexpected error{}",

This comment has been minimized.

@paulmillar

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: {}"

This comment has been minimized.

@anmolnar

anmolnar Dec 15, 2017

Contributor

No, because the RETRY_CONN_MSG should go right after it. (starts with ", ")

@anmolnar

This comment has been minimized.

Contributor

anmolnar commented Dec 18, 2017

@paulmillar Please approve it, if you're happy with the change.
@phunt Do you think it can be committed?

@asfgit asfgit closed this in e129e7a Dec 19, 2017

asfgit pushed a commit that referenced this pull request Dec 19, 2017

ZOOKEEPER-2893: very poor choice of logging if client fails to connec…
…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>

asfgit pushed a commit that referenced this pull request Dec 19, 2017

ZOOKEEPER-2893: very poor choice of logging if client fails to connec…
…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)

lvfangmin pushed a commit to lvfangmin/zookeeper that referenced this pull request Jun 17, 2018

ZOOKEEPER-2893: very poor choice of logging if client fails to connec…
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment