[7.x][ML] Do not fail DFA task when it's stopped whilst reindexing (#55797) (#55800)

Adding to #55659, we missed another way we could set the task to
failed due to task cancellation. CI revealed that we might also
get a `SearchPhaseExecutionException` whose cause is a
`TaskCancelledException`. That exception is not wrapped so
unwrapping it will not return the underlying `TaskCancelledException`.
Thus to be complete in catching this, we also need to check the
error's cause.

Closes #55068

Backport of #55797
This commit is contained in:
Dimitris Athanasiou 2020-04-27 16:03:57 +03:00 committed by GitHub
parent 7f100c1196
commit abab4c4d4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -229,7 +229,7 @@ public class DataFrameAnalyticsManager {
startAnalytics(task, config);
},
error -> {
if (ExceptionsHelper.unwrapCause(error) instanceof TaskCancelledException && task.isStopping()) {
if (task.isStopping() && isTaskCancelledException(error)) {
LOGGER.debug(new ParameterizedMessage("[{}] Caught task cancelled exception while task is stopping",
config.getId()), error);
task.markAsCompleted();
@ -294,6 +294,11 @@ public class DataFrameAnalyticsManager {
new GetIndexRequest().indices(config.getDest().getIndex()), destIndexListener);
}
private static boolean isTaskCancelledException(Exception error) {
return ExceptionsHelper.unwrapCause(error) instanceof TaskCancelledException
|| ExceptionsHelper.unwrapCause(error.getCause()) instanceof TaskCancelledException;
}
private void startAnalytics(DataFrameAnalyticsTask task, DataFrameAnalyticsConfig config) {
if (task.isStopping()) {
LOGGER.debug("[{}] task is stopping. Marking as complete before starting analysis.", task.getParams().getId());