Skip to content
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 from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/java/main/org/apache/zookeeper/ClientCnxn.java
Expand Up @@ -1041,6 +1041,8 @@ private void sendPing() {

private InetSocketAddress rwServerAddress = null;

private InetSocketAddress addr = null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


private final static int minPingRwTimeout = 100;

private final static int maxPingRwTimeout = 60000;
Expand All @@ -1063,7 +1065,6 @@ private void startConnect() throws IOException {
}
state = States.CONNECTING;

InetSocketAddress addr;
if (rwServerAddress != null) {
addr = rwServerAddress;
rwServerAddress = null;
Expand Down Expand Up @@ -1232,11 +1233,12 @@ public void run() {
} else if (e instanceof RWServerFoundException) {
LOG.info(e.getMessage());
} else {
SocketAddress remoteAddr = clientCnxnSocket.getRemoteSocketAddress();
LOG.warn(
"Session 0x"
+ Long.toHexString(getSessionId())
+ " for server "
+ clientCnxnSocket.getRemoteSocketAddress()
+ (remoteAddr == null ? addr : remoteAddr)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course this comment is [non-blocking]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

+ ", unexpected error"
+ RETRY_CONN_MSG, e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}
Expand Down