|
44 | 44 | import org.elasticsearch.core.TimeValue;
|
45 | 45 | import org.elasticsearch.index.Index;
|
46 | 46 | import org.elasticsearch.index.IndexNotFoundException;
|
| 47 | +import org.elasticsearch.index.engine.VersionConflictEngineException; |
47 | 48 | import org.elasticsearch.index.shard.ShardId;
|
48 | 49 | import org.elasticsearch.indices.IndexClosedException;
|
49 | 50 | import org.elasticsearch.node.NodeClosedException;
|
@@ -478,15 +479,18 @@ private void completeShardOperation() {
|
478 | 479 | }
|
479 | 480 |
|
480 | 481 | private void processFailure(BulkItemRequest bulkItemRequest, Exception cause) {
|
481 |
| - var errorType = ElasticsearchException.getExceptionName(ExceptionsHelper.unwrapCause(cause)); |
| 482 | + var error = ExceptionsHelper.unwrapCause(cause); |
| 483 | + var errorType = ElasticsearchException.getExceptionName(error); |
482 | 484 | DocWriteRequest<?> docWriteRequest = bulkItemRequest.request();
|
483 | 485 | DataStream failureStoreCandidate = getRedirectTargetCandidate(docWriteRequest, getClusterState().metadata());
|
484 | 486 | // If the candidate is not null, the BulkItemRequest targets a data stream, but we'll still have to check if
|
485 | 487 | // it has the failure store enabled.
|
486 | 488 | if (failureStoreCandidate != null) {
|
487 | 489 | // Do not redirect documents to a failure store that were already headed to one.
|
488 | 490 | var isFailureStoreDoc = docWriteRequest instanceof IndexRequest indexRequest && indexRequest.isWriteToFailureStore();
|
489 |
| - if (isFailureStoreDoc == false && failureStoreCandidate.isFailureStoreEnabled()) { |
| 491 | + if (isFailureStoreDoc == false |
| 492 | + && failureStoreCandidate.isFailureStoreEnabled() |
| 493 | + && error instanceof VersionConflictEngineException == false) { |
490 | 494 | // Redirect to failure store.
|
491 | 495 | maybeMarkFailureStoreForRollover(failureStoreCandidate);
|
492 | 496 | addDocumentToRedirectRequests(bulkItemRequest, cause, failureStoreCandidate.getName());
|
|
0 commit comments