Provide a better error message for the case when all shards failed (#28333)
Today we don't specify a cause which can make debugging very very tricky. This change is best effort to supply at least one cause for the failure.
This commit is contained in:
parent
ba9e2e44cb
commit
d31e964a86
|
@ -122,14 +122,14 @@ abstract class AbstractSearchAsyncAction<Result extends SearchPhaseResult> exten
|
||||||
* at least one successful operation left and if so we move to the next phase. If not we immediately fail the
|
* at least one successful operation left and if so we move to the next phase. If not we immediately fail the
|
||||||
* search phase as "all shards failed"*/
|
* search phase as "all shards failed"*/
|
||||||
if (successfulOps.get() == 0) { // we have 0 successful results that means we shortcut stuff and return a failure
|
if (successfulOps.get() == 0) { // we have 0 successful results that means we shortcut stuff and return a failure
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
final ShardOperationFailedException[] shardSearchFailures = ExceptionsHelper.groupBy(buildShardFailures());
|
final ShardOperationFailedException[] shardSearchFailures = ExceptionsHelper.groupBy(buildShardFailures());
|
||||||
Throwable cause = shardSearchFailures.length == 0 ? null :
|
Throwable cause = shardSearchFailures.length == 0 ? null :
|
||||||
ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0];
|
ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0];
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug((Supplier<?>) () -> new ParameterizedMessage("All shards failed for phase: [{}]", getName()),
|
logger.debug((Supplier<?>) () -> new ParameterizedMessage("All shards failed for phase: [{}]", getName()),
|
||||||
cause);
|
cause);
|
||||||
}
|
}
|
||||||
onPhaseFailure(currentPhase, "all shards failed", null);
|
onPhaseFailure(currentPhase, "all shards failed", cause);
|
||||||
} else {
|
} else {
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
final String resultsFrom = results.getSuccessfulResults()
|
final String resultsFrom = results.getSuccessfulResults()
|
||||||
|
|
Loading…
Reference in New Issue