From 7ea4f7400baaa638a78cf24baed09d4283f1e4ac Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Mon, 8 Feb 2016 13:14:14 +0100 Subject: [PATCH] Require that relocation source is marked as relocating before starting recovery to relocation target --- .../elasticsearch/indices/recovery/RecoverySource.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java index f24452bf007..105dd3c445f 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java @@ -93,6 +93,14 @@ public class RecoverySource extends AbstractComponent implements IndexEventListe logger.debug("delaying recovery of {} as source node {} is unknown", request.shardId(), request.targetNode()); throw new DelayRecoveryException("source node does not have the node [" + request.targetNode() + "] in its state yet.."); } + + ShardRouting routingEntry = shard.routingEntry(); + if (request.recoveryType() == RecoveryState.Type.PRIMARY_RELOCATION && + (routingEntry.relocating() == false || routingEntry.relocatingNodeId().equals(request.targetNode().getId()) == false)) { + logger.debug("delaying recovery of {} as source shard is not marked yet as relocating to {}", request.shardId(), request.targetNode()); + throw new DelayRecoveryException("source shard is not marked yet as relocating to [" + request.targetNode() + "]"); + } + ShardRouting targetShardRouting = null; for (ShardRouting shardRouting : node) { if (shardRouting.shardId().equals(request.shardId())) {