From 12ef12f7aa3592d781da35a936ef57253665481b Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 12 Aug 2010 21:44:27 +0300 Subject: [PATCH] better handling of closing a shard / index while retrying recovery --- .../index/shard/recovery/RecoveryTarget.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java index dbcf594517a..9262f7433eb 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.index.IndexShardMissingException; import org.elasticsearch.index.engine.RecoveryEngineException; +import org.elasticsearch.index.service.IndexService; import org.elasticsearch.index.shard.*; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.shard.service.InternalIndexShard; @@ -104,7 +105,16 @@ public class RecoveryTarget extends AbstractComponent { listener.onIgnoreRecovery(false, "No node to recovery from, retry on next cluster state update"); return; } - final InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id()); + IndexService indexService = indicesService.indexService(request.shardId().index().name()); + if (indexService == null) { + listener.onIgnoreRecovery(false, "index missing, stop recovery"); + return; + } + final InternalIndexShard shard = (InternalIndexShard) indexService.shard(request.shardId().id()); + if (shard == null) { + listener.onIgnoreRecovery(false, "shard missing, stop recovery"); + return; + } if (!fromRetry) { try { shard.recovering();