Skip to content
Merged
Changes from all commits
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 @@ -574,7 +574,12 @@ public void handleResponse(NodeQueryResponse response) {
onShardResult(q);
}
case null, default -> {
assert false : "impossible [" + response.results[i] + "]";
var e = new IllegalStateException("data node returned unexpected result for shard [" + s.shardId + "]");
logger.error(
"data node produced unexpected result[" + response.results[i] + "] for shard [" + s.shardId + "]",
e
);
onShardFailure(shardIdx, target, shardIterators[shardIdx], e);
}
}
}
Expand Down Expand Up @@ -950,7 +955,7 @@ private void writeSuccessfulResponse(RecyclerBytesStreamOutput out) throws IOExc
for (int i = 0; i < resultCount; i++) {
var result = queryPhaseResultConsumer.results.get(i);
if (result == null) {
NodeQueryResponse.writePerShardException(out, failures.remove(i));
NodeQueryResponse.writePerShardException(out, shardFailureOrUnknown(i));
} else {
// free context id and remove it from the result right away in case we don't need it anymore
maybeFreeContext(result, relevantShardIndices, namedWriteableRegistry);
Expand All @@ -968,7 +973,7 @@ private void writeReductionFailureResponse(RecyclerBytesStreamOutput out, Except
for (int i = 0; i < resultCount; i++) {
var result = queryPhaseResultConsumer.results.get(i);
if (result == null) {
NodeQueryResponse.writePerShardException(out, failures.remove(i));
NodeQueryResponse.writePerShardException(out, shardFailureOrUnknown(i));
} else {
NodeQueryResponse.writePerShardResult(out, result);
}
Expand All @@ -978,6 +983,17 @@ private void writeReductionFailureResponse(RecyclerBytesStreamOutput out, Except
releaseAllResultsContexts();
}

private Exception shardFailureOrUnknown(int localIndex) {
Exception failure = failures.remove(localIndex);
if (failure == null) {
logger.error("data node produced null failure for shard [{}]", localIndex);
failure = new IllegalStateException(
"shard [" + searchRequest.shards.get(localIndex).shardId + "] neither succeeded nor failed"
);
}
return failure;
}

/**
* This code is strictly for _snapshot_ backwards compatibility. The feature flag
* {@link SearchService#BATCHED_QUERY_PHASE_FEATURE_FLAG} was not turned on when the transport version
Expand Down
Loading