[Transform] improve irrecoverable error detection

treat resource not found and illegal argument exceptions as irrecoverable error

relates #50135
This commit is contained in:
Hendrik Muhs 2020-02-04 10:35:31 +01:00
parent ba2810f23d
commit 5d5f3ce256
3 changed files with 31 additions and 25 deletions

View File

@ -174,7 +174,7 @@ class ClientTransformIndexer extends TransformIndexer {
// Determine whether the failure is irrecoverable (transform should go into failed state) or not (transform increments // Determine whether the failure is irrecoverable (transform should go into failed state) or not (transform increments
// the indexing failure counter // the indexing failure counter
// and possibly retries) // and possibly retries)
Exception irrecoverableException = ExceptionRootCauseFinder.getFirstIrrecoverableExceptionFromBulkResponses( Throwable irrecoverableException = ExceptionRootCauseFinder.getFirstIrrecoverableExceptionFromBulkResponses(
deduplicatedFailures.values() deduplicatedFailures.values()
); );
if (irrecoverableException == null) { if (irrecoverableException == null) {
@ -373,7 +373,7 @@ class ClientTransformIndexer extends TransformIndexer {
return failureMessage; return failureMessage;
} }
private static Exception decorateBulkIndexException(Exception irrecoverableException) { private static Throwable decorateBulkIndexException(Throwable irrecoverableException) {
if (irrecoverableException instanceof MapperParsingException) { if (irrecoverableException instanceof MapperParsingException) {
return new TransformException( return new TransformException(
"Destination index mappings are incompatible with the transform configuration.", "Destination index mappings are incompatible with the transform configuration.",

View File

@ -484,7 +484,9 @@ public abstract class TransformIndexer extends AsyncTwoPhaseIndexer<TransformInd
handleIrrecoverableBulkIndexingException((BulkIndexingException) unwrappedException); handleIrrecoverableBulkIndexingException((BulkIndexingException) unwrappedException);
} else if (unwrappedException instanceof IndexNotFoundException } else if (unwrappedException instanceof IndexNotFoundException
|| unwrappedException instanceof AggregationResultUtils.AggregationExtractionException || unwrappedException instanceof AggregationResultUtils.AggregationExtractionException
|| unwrappedException instanceof TransformConfigReloadingException) { || unwrappedException instanceof TransformConfigReloadingException
|| unwrappedException instanceof ResourceNotFoundException
|| unwrappedException instanceof IllegalArgumentException) {
failIndexer("task encountered irrecoverable failure: " + e.getMessage()); failIndexer("task encountered irrecoverable failure: " + e.getMessage());
} else if (context.getAndIncrementFailureCount() > context.getNumFailureRetries()) { } else if (context.getAndIncrementFailureCount() > context.getNumFailureRetries()) {
failIndexer( failIndexer(

View File

@ -7,6 +7,7 @@
package org.elasticsearch.xpack.transform.utils; package org.elasticsearch.xpack.transform.utils;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.action.search.ShardSearchFailure; import org.elasticsearch.action.search.ShardSearchFailure;
@ -63,10 +64,13 @@ public final class ExceptionRootCauseFinder {
* @param failures a collection of bulk item responses * @param failures a collection of bulk item responses
* @return The first exception considered irrecoverable if there are any, null if no irrecoverable exception found * @return The first exception considered irrecoverable if there are any, null if no irrecoverable exception found
*/ */
public static Exception getFirstIrrecoverableExceptionFromBulkResponses(Collection<BulkItemResponse> failures) { public static Throwable getFirstIrrecoverableExceptionFromBulkResponses(Collection<BulkItemResponse> failures) {
for (BulkItemResponse failure : failures) { for (BulkItemResponse failure : failures) {
if (failure.getFailure().getCause() instanceof MapperParsingException) { Throwable unwrappedThrowable = org.elasticsearch.ExceptionsHelper.unwrapCause(failure.getFailure().getCause());
return failure.getFailure().getCause(); if (unwrappedThrowable instanceof MapperParsingException
|| unwrappedThrowable instanceof IllegalArgumentException
|| unwrappedThrowable instanceof ResourceNotFoundException) {
return unwrappedThrowable;
} }
} }