From 5f2b7dc2660381e4b9c582ed743708a3a511a43e Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Thu, 31 Oct 2013 14:23:20 +0100 Subject: [PATCH] improve moving from post_recovery to started we need to move to started from post recovery on cluster level changes, we need to make sure we handle a global state change of relocating, which can happen (and not pass through started) --- ...nsportShardReplicationOperationAction.java | 12 +++--- .../shard/service/InternalIndexShard.java | 39 ++++++++++++------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java b/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java index 2bc0e77b5e6..0e242828147 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java +++ b/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java @@ -483,16 +483,16 @@ public abstract class TransportShardReplicationOperationAction[{}], reason [global state is [{}]]", state, IndexShardState.STARTED, newRouting.state()); + state = IndexShardState.STARTED; + movedToStarted = true; + } else { + logger.debug("state [{}] not changed, not in POST_RECOVERY, global state is [{}]", state, newRouting.state()); + } + } + if (movedToStarted) { + indicesLifecycle.afterIndexShardStarted(this); } - logger.debug("state: [{}]->[{}], reason [global state moved to started]", state, IndexShardState.STARTED); - state = IndexShardState.STARTED; } - indicesLifecycle.afterIndexShardStarted(this); } + this.shardRouting = newRouting; indicesLifecycle.shardRoutingChanged(this, currentRouting, newRouting); + return this; }