Skip to content

Commit a7119ef

Browse files
committed
Gateway: improve assertion at the end of shard recovery
we want to make sure the recovery finished all the way to post recovery. Current check, validating the shard is either in POST_RECOVERY or STARTED is not good because the shard could be also closed if things go fast enough (like in our tests). The assertion is changed to check the shard is not left in CREATED or RECOVERING. Closes #10028
1 parent 9663fa4 commit a7119ef

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,10 @@ public void run() {
112112
shardGateway.recover(indexShouldExists, recoveryState);
113113
}
114114

115-
// Check that the gateway have set the shard to POST_RECOVERY. Note that if a shard
116-
// is in POST_RECOVERY, it may have been started as well if:
117-
// 1) master sent a new cluster state indicating shard is initializing
118-
// 2) IndicesClusterStateService#applyInitializingShard will send a shard started event
119-
// 3) Master will mark shard as started and this will be processed locally.
115+
// Check that the gateway didn't leave the shard in init or recovering stage. it is up to the gateway
116+
// to call post recovery.
120117
IndexShardState shardState = indexShard.state();
121-
assert shardState == IndexShardState.POST_RECOVERY || shardState == IndexShardState.STARTED : "recovery process didn't call post_recovery. shardState [" + shardState + "]";
118+
assert shardState != IndexShardState.CREATED && shardState != IndexShardState.RECOVERING : "recovery process of " + shardId + " didn't get to post_recovery. shardState [" + shardState + "]";
122119

123120
if (logger.isTraceEnabled()) {
124121
StringBuilder sb = new StringBuilder();

0 commit comments

Comments
 (0)