diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java index 572b784093e..295ab49ac7f 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java @@ -435,6 +435,7 @@ public class RecoverySourceHandler { exception.addSuppressed(remoteException); logger.warn("{} Remote file corruption during finalization on node {}, recovering {}. local checksum OK", corruptIndexException, shard.shardId(), request.targetNode()); + throw exception; } else { throw remoteException; } diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java index 0388265e64c..a953206fa89 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java @@ -406,9 +406,13 @@ public class RecoveryTarget extends AbstractComponent { logger.debug("Failed to clean lucene index", e); ex.addSuppressed(e); } - throw new RecoveryFailedException(recoveryStatus.state(), "failed to clean after recovery", ex); + RecoveryFailedException rfe = new RecoveryFailedException(recoveryStatus.state(), "failed to clean after recovery", ex); + recoveryStatus.fail(rfe, true); + throw rfe; } catch (Exception ex) { - throw new RecoveryFailedException(recoveryStatus.state(), "failed to clean after recovery", ex); + RecoveryFailedException rfe = new RecoveryFailedException(recoveryStatus.state(), "failed to clean after recovery", ex); + recoveryStatus.fail(rfe, true); + throw rfe; } channel.sendResponse(TransportResponse.Empty.INSTANCE); }