From 72a9bffff8ca4f1c21d2319f56bea4d63bb38392 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Fri, 21 Apr 2017 16:43:06 +0100 Subject: [PATCH] [ML] Proceed on conflict when deleting job docs. (elastic/x-pack-elasticsearch#1157) Original commit: elastic/x-pack-elasticsearch@b1b98ec268132c78d5cba0393769a1182c0399cf --- .../ml/job/persistence/JobStorageDeletionTask.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 faa621d4d0b..59cc2f1ec9c 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 @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.job.persistence; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; +import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.byscroll.BulkByScrollResponse; import org.elasticsearch.action.bulk.byscroll.DeleteByQueryRequest; @@ -63,8 +64,12 @@ public class JobStorageDeletionTask extends Task { logger.warn("[{}] DeleteByQuery for indices [{}, {}] timed out.", jobId, indexName, indexPattern); } if (!bulkByScrollResponse.getBulkFailures().isEmpty()) { - logger.warn("[{}] {} failures encountered while running DeleteByQuery on indices [{}, {}].", - jobId, bulkByScrollResponse.getBulkFailures().size(), indexName, indexPattern); + logger.warn("[{}] {} failures and {} conflicts encountered while running DeleteByQuery on indices [{}, {}].", + jobId, bulkByScrollResponse.getBulkFailures().size(), bulkByScrollResponse.getVersionConflicts(), + indexName, indexPattern); + for (BulkItemResponse.Failure failure : bulkByScrollResponse.getBulkFailures()) { + logger.warn("DBQ failure: " + failure); + } } deleteAlias(jobId, aliasName, indexName, client, deleteAliasHandler); }, @@ -81,6 +86,7 @@ public class JobStorageDeletionTask extends Task { searchRequest.source(new SearchSourceBuilder().query(query)); searchRequest.indicesOptions(JobProvider.addIgnoreUnavailable(IndicesOptions.lenientExpandOpen())); request.setSlices(5); + request.setAbortOnVersionConflict(false); client.execute(XPackDeleteByQueryAction.INSTANCE, request, dbqHandler); },