|
|
@@ -19,7 +19,6 @@ import org.elasticsearch.action.support.IndicesOptions;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.breaker.CircuitBreakingException;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
-import org.elasticsearch.index.IndexNotFoundException;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
|
import org.elasticsearch.script.ScriptException;
|
|
|
@@ -42,7 +41,6 @@ import org.elasticsearch.xpack.core.transform.utils.ExceptionsHelper;
|
|
|
import org.elasticsearch.xpack.transform.checkpoint.CheckpointProvider;
|
|
|
import org.elasticsearch.xpack.transform.notifications.TransformAuditor;
|
|
|
import org.elasticsearch.xpack.transform.persistence.TransformConfigManager;
|
|
|
-import org.elasticsearch.xpack.transform.transforms.pivot.AggregationResultUtils;
|
|
|
import org.elasticsearch.xpack.transform.transforms.pivot.Pivot;
|
|
|
import org.elasticsearch.xpack.transform.utils.ExceptionRootCauseFinder;
|
|
|
|
|
|
@@ -287,7 +285,7 @@ public abstract class TransformIndexer extends AsyncTwoPhaseIndexer<TransformInd
|
|
|
// If the transform config index or the transform config is gone, something serious occurred
|
|
|
// We are in an unknown state and should fail out
|
|
|
if (failure instanceof ResourceNotFoundException) {
|
|
|
- updateConfigListener.onFailure(new TransformConfigReloadingException(msg, failure));
|
|
|
+ updateConfigListener.onFailure(new TransformConfigLostOnReloadException(msg, failure));
|
|
|
} else {
|
|
|
auditor.warning(getJobId(), msg);
|
|
|
updateConfigListener.onResponse(null);
|
|
|
@@ -477,37 +475,54 @@ public abstract class TransformIndexer extends AsyncTwoPhaseIndexer<TransformInd
|
|
|
|
|
|
if (unwrappedException instanceof CircuitBreakingException) {
|
|
|
handleCircuitBreakingException((CircuitBreakingException) unwrappedException);
|
|
|
- } else if (unwrappedException instanceof ScriptException) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (unwrappedException instanceof ScriptException) {
|
|
|
handleScriptException((ScriptException) unwrappedException);
|
|
|
- // irrecoverable error without special handling
|
|
|
- } else if (unwrappedException instanceof BulkIndexingException && ((BulkIndexingException) unwrappedException).isIrrecoverable()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (unwrappedException instanceof BulkIndexingException && ((BulkIndexingException) unwrappedException).isIrrecoverable()) {
|
|
|
handleIrrecoverableBulkIndexingException((BulkIndexingException) unwrappedException);
|
|
|
- } else if (unwrappedException instanceof IndexNotFoundException
|
|
|
- || unwrappedException instanceof AggregationResultUtils.AggregationExtractionException
|
|
|
- || unwrappedException instanceof TransformConfigReloadingException
|
|
|
- || unwrappedException instanceof ResourceNotFoundException
|
|
|
- || unwrappedException instanceof IllegalArgumentException) {
|
|
|
- failIndexer("task encountered irrecoverable failure: " + e.getMessage());
|
|
|
- } else if (context.getAndIncrementFailureCount() > context.getNumFailureRetries()) {
|
|
|
- failIndexer(
|
|
|
- "task encountered more than "
|
|
|
- + context.getNumFailureRetries()
|
|
|
- + " failures; latest failure: "
|
|
|
- + ExceptionRootCauseFinder.getDetailedMessage(unwrappedException)
|
|
|
- );
|
|
|
- } else {
|
|
|
- // Since our schedule fires again very quickly after failures it is possible to run into the same failure numerous
|
|
|
- // times in a row, very quickly. We do not want to spam the audit log with repeated failures, so only record the first one
|
|
|
- if (e.getMessage().equals(lastAuditedExceptionMessage) == false) {
|
|
|
- String message = ExceptionRootCauseFinder.getDetailedMessage(unwrappedException);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- auditor.warning(
|
|
|
- getJobId(),
|
|
|
- "Transform encountered an exception: " + message + " Will attempt again at next scheduled trigger."
|
|
|
- );
|
|
|
- lastAuditedExceptionMessage = message;
|
|
|
- }
|
|
|
+ // irrecoverable error without special handling
|
|
|
+ if (unwrappedException instanceof ElasticsearchException) {
|
|
|
+ ElasticsearchException elasticsearchException = (ElasticsearchException) unwrappedException;
|
|
|
+ if (ExceptionRootCauseFinder.IRRECOVERABLE_REST_STATUSES.contains(elasticsearchException.status())) {
|
|
|
+ failIndexer("task encountered irrecoverable failure: " + elasticsearchException.getDetailedMessage());
|
|
|
+ return;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ if (unwrappedException instanceof IllegalArgumentException) {
|
|
|
+ failIndexer("task encountered irrecoverable failure: " + e.getMessage());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (context.getAndIncrementFailureCount() > context.getNumFailureRetries()) {
|
|
|
+ failIndexer(
|
|
|
+ "task encountered more than "
|
|
|
+ + context.getNumFailureRetries()
|
|
|
+ + " failures; latest failure: "
|
|
|
+ + ExceptionRootCauseFinder.getDetailedMessage(unwrappedException)
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Since our schedule fires again very quickly after failures it is possible to run into the same failure numerous
|
|
|
+ // times in a row, very quickly. We do not want to spam the audit log with repeated failures, so only record the first one
|
|
|
+ if (e.getMessage().equals(lastAuditedExceptionMessage) == false) {
|
|
|
+ String message = ExceptionRootCauseFinder.getDetailedMessage(unwrappedException);
|
|
|
+
|
|
|
+ auditor.warning(
|
|
|
+ getJobId(),
|
|
|
+ "Transform encountered an exception: " + message + " Will attempt again at next scheduled trigger."
|
|
|
+ );
|
|
|
+ lastAuditedExceptionMessage = message;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -901,8 +916,12 @@ public abstract class TransformIndexer extends AsyncTwoPhaseIndexer<TransformInd
|
|
|
return RunState.PARTIAL_RUN_IDENTIFY_CHANGES;
|
|
|
}
|
|
|
|
|
|
- static class TransformConfigReloadingException extends ElasticsearchException {
|
|
|
- TransformConfigReloadingException(String msg, Throwable cause, Object... args) {
|
|
|
+ /**
|
|
|
+ * Thrown when the transform configuration disappeared permanently.
|
|
|
+ * (not if reloading failed due to an intermittent problem)
|
|
|
+ */
|
|
|
+ static class TransformConfigLostOnReloadException extends ResourceNotFoundException {
|
|
|
+ TransformConfigLostOnReloadException(String msg, Throwable cause, Object... args) {
|
|
|
super(msg, cause, args);
|
|
|
}
|
|
|
}
|