Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,21 @@ public void handleException(TransportException exp) {
}

if (exp instanceof ConnectTransportException || exp.getCause() instanceof ConnectTransportException) {
logger.debug(new ParameterizedMessage("leader [{}] disconnected, failing immediately", leader), exp);
if (logger.isDebugEnabled()) {
logger.debug(new ParameterizedMessage(
"leader [{}] disconnected during check, restarting discovery", leader), exp);
} else {
logger.info("leader [{}] disconnected during check, restarting discovery", leader);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of logging here at info level, I would prefer to pass the necessary info (message + exception) to Coordinator.getOnLeaderFailure and let that one do the logging if it effectively turns the node back to candidate.
Also I would prefer not to use the "leader" terminology when logging at info level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I've moved the logging to the Coordinator in bd0c29c.

}
leaderFailed();
return;
}

long failureCount = failureCountSinceLastSuccess.incrementAndGet();
if (failureCount >= leaderCheckRetryCount) {
logger.debug(new ParameterizedMessage("{} consecutive failures (limit [{}] is {}) so leader [{}] has failed",
failureCount, LEADER_CHECK_RETRY_COUNT_SETTING.getKey(), leaderCheckRetryCount, leader), exp);
logger.info(new ParameterizedMessage(
"leader [{}] has failed {} consecutive checks (limit [{}] is {}), restarting discovery; last failure was:",
leader, failureCount, LEADER_CHECK_RETRY_COUNT_SETTING.getKey(), leaderCheckRetryCount), exp);
leaderFailed();
return;
}
Expand All @@ -269,6 +275,7 @@ void leaderFailed() {

void handleDisconnectedNode(DiscoveryNode discoveryNode) {
if (discoveryNode.equals(leader)) {
logger.info("leader [{}] disconnected, restarting discovery", leader);
leaderFailed();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.cluster.node.DiscoveryNode;
Expand Down Expand Up @@ -89,6 +90,13 @@ protected void doRun() throws Exception {
remoteNode = transportService.handshake(connection, probeHandshakeTimeout.millis());
// success means (amongst other things) that the cluster names match
logger.trace("[{}] handshake successful: {}", this, remoteNode);
} catch (Exception e) {
// we opened a connection and successfully performed a low-level handshake, so we were definitely talking to an
// Elasticsearch node, but the high-level handshake failed indicating some kind of mismatched configurations
// (e.g. cluster name) that the user should address
logger.warn(new ParameterizedMessage("handshake failed for [{}]", this), e);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we do this only for the handshake bit? Can we avoid logging if it is truly a connection failure? e.g. ConnectTransportException.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't follow. As the comment says, we know that we successfully connected and performed a low-level handshake, so even a ConnectTransportException here seems worthy of a warning.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wanted to avoid for a flaky network connection to cause extra verbose warnings here. I'm fine if you want to leave it this way though

listener.onFailure(e);
return;
} finally {
IOUtils.closeWhileHandlingException(connection);
}
Expand Down