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:
parent
7f100c1196
commit
abab4c4d4f
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue