|
7 | 7 |
|
8 | 8 | import org.apache.logging.log4j.LogManager; |
9 | 9 | import org.apache.logging.log4j.Logger; |
| 10 | +import org.apache.logging.log4j.message.ParameterizedMessage; |
10 | 11 | import org.elasticsearch.ElasticsearchException; |
11 | 12 | import org.elasticsearch.action.ActionListener; |
12 | 13 | import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; |
|
27 | 28 | import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest; |
28 | 29 | import org.elasticsearch.action.admin.indices.segments.ShardSegments; |
29 | 30 | import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; |
| 31 | +import org.elasticsearch.action.bulk.BulkItemResponse; |
30 | 32 | import org.elasticsearch.action.support.master.AcknowledgedResponse; |
31 | 33 | import org.elasticsearch.client.Client; |
32 | 34 | import org.elasticsearch.cluster.ClusterState; |
|
47 | 49 | import org.elasticsearch.index.reindex.BulkByScrollResponse; |
48 | 50 | import org.elasticsearch.index.reindex.ReindexAction; |
49 | 51 | import org.elasticsearch.index.reindex.ReindexRequest; |
| 52 | +import org.elasticsearch.index.reindex.ScrollableHitSource; |
50 | 53 | import org.elasticsearch.search.builder.SearchSourceBuilder; |
51 | 54 | import org.elasticsearch.xpack.core.enrich.EnrichPolicy; |
52 | 55 | import org.elasticsearch.xpack.core.enrich.action.ExecuteEnrichPolicyStatus; |
@@ -352,8 +355,45 @@ private void transferDataToEnrichIndex(final String destinationIndexName) { |
352 | 355 | public void onResponse(BulkByScrollResponse bulkByScrollResponse) { |
353 | 356 | // Do we want to fail the request if there were failures during the reindex process? |
354 | 357 | if (bulkByScrollResponse.getBulkFailures().size() > 0) { |
| 358 | + logger.warn( |
| 359 | + "Policy [{}]: encountered [{}] bulk failures. Turn on DEBUG logging for details.", |
| 360 | + policyName, |
| 361 | + bulkByScrollResponse.getBulkFailures().size() |
| 362 | + ); |
| 363 | + if (logger.isDebugEnabled()) { |
| 364 | + for (BulkItemResponse.Failure failure : bulkByScrollResponse.getBulkFailures()) { |
| 365 | + logger.debug( |
| 366 | + new ParameterizedMessage( |
| 367 | + "Policy [{}]: bulk index failed for index [{}], id [{}]", |
| 368 | + policyName, |
| 369 | + failure.getIndex(), |
| 370 | + failure.getId() |
| 371 | + ), |
| 372 | + failure.getCause() |
| 373 | + ); |
| 374 | + } |
| 375 | + } |
355 | 376 | listener.onFailure(new ElasticsearchException("Encountered bulk failures during reindex process")); |
356 | 377 | } else if (bulkByScrollResponse.getSearchFailures().size() > 0) { |
| 378 | + logger.warn( |
| 379 | + "Policy [{}]: encountered [{}] search failures. Turn on DEBUG logging for details.", |
| 380 | + policyName, |
| 381 | + bulkByScrollResponse.getSearchFailures().size() |
| 382 | + ); |
| 383 | + if (logger.isDebugEnabled()) { |
| 384 | + for (ScrollableHitSource.SearchFailure failure : bulkByScrollResponse.getSearchFailures()) { |
| 385 | + logger.debug( |
| 386 | + new ParameterizedMessage( |
| 387 | + "Policy [{}]: search failed for index [{}], shard [{}] on node [{}]", |
| 388 | + policyName, |
| 389 | + failure.getIndex(), |
| 390 | + failure.getShardId(), |
| 391 | + failure.getNodeId() |
| 392 | + ), |
| 393 | + failure.getReason() |
| 394 | + ); |
| 395 | + } |
| 396 | + } |
357 | 397 | listener.onFailure(new ElasticsearchException("Encountered search failures during reindex process")); |
358 | 398 | } else { |
359 | 399 | logger.info( |
|
0 commit comments