diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java index cf914491a45..6189afb06d8 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java @@ -109,7 +109,16 @@ public class JobStorageDeletionTask extends Task { private void deleteQuantiles(String jobId, Client client, ActionListener finishedHandler) { client.prepareDelete(AnomalyDetectorsIndex.jobStateIndexName(), Quantiles.TYPE.getPreferredName(), Quantiles.documentId(jobId)) - .execute(finishedHandler); + .execute(ActionListener.wrap( + finishedHandler::onResponse, + e -> { + // It's not a problem for us if the index wasn't found - it's equivalent to document not found + if (e instanceof IndexNotFoundException) { + finishedHandler.onResponse(new DeleteResponse()); + } else { + finishedHandler.onFailure(e); + } + })); } private void deleteModelState(String jobId, Client client, ActionListener listener) {