Improve log message in TransportNodesAction
Today when handling responses from nodes in TransportNodesAction, if a node timeouts or some other failure occurs and the action is not accumulating exceptions, we log a confusing message: org.elasticsearch.action.admin.cluster.stats.TransportClusterStatsAction] ignoring unexpected response [null] of type [null], expected [ClusterStatsNodeResponse] or [FailedNodeException] Moreover, the original exception is completely lost. Since this log message is confusing and unhelpful, we can drop it. Instead, we hold onto the exception and log it at the warn level before dropping it from the response. Relates #21476
This commit is contained in:
parent
aeb97ff412
commit
fdbe336104
|
@ -106,17 +106,18 @@ public abstract class TransportNodesAction<NodesRequest extends BaseNodesRequest
|
|||
final List<NodeResponse> responses = new ArrayList<>();
|
||||
final List<FailedNodeException> failures = new ArrayList<>();
|
||||
|
||||
final boolean accumulateExceptions = accumulateExceptions();
|
||||
for (int i = 0; i < nodesResponses.length(); ++i) {
|
||||
Object response = nodesResponses.get(i);
|
||||
|
||||
if (nodeResponseClass.isInstance(response)) {
|
||||
responses.add(nodeResponseClass.cast(response));
|
||||
} else if (response instanceof FailedNodeException) {
|
||||
failures.add((FailedNodeException)response);
|
||||
if (response instanceof FailedNodeException) {
|
||||
if (accumulateExceptions) {
|
||||
failures.add((FailedNodeException)response);
|
||||
} else {
|
||||
logger.warn("not accumulating exceptions, excluding exception from response", (FailedNodeException)response);
|
||||
}
|
||||
} else {
|
||||
logger.warn("ignoring unexpected response [{}] of type [{}], expected [{}] or [{}]",
|
||||
response, response != null ? response.getClass().getName() : null,
|
||||
nodeResponseClass.getSimpleName(), FailedNodeException.class.getSimpleName());
|
||||
responses.add(nodeResponseClass.cast(response));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,9 +244,7 @@ public abstract class TransportNodesAction<NodesRequest extends BaseNodesRequest
|
|||
(org.apache.logging.log4j.util.Supplier<?>)
|
||||
() -> new ParameterizedMessage("failed to execute on node [{}]", nodeId), t);
|
||||
}
|
||||
if (accumulateExceptions()) {
|
||||
responses.set(idx, new FailedNodeException(nodeId, "Failed node [" + nodeId + "]", t));
|
||||
}
|
||||
responses.set(idx, new FailedNodeException(nodeId, "Failed node [" + nodeId + "]", t));
|
||||
if (counter.incrementAndGet() == responses.length()) {
|
||||
finishHim();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue