Skip to content

Commit

Permalink
introduce new REMOTE_METADATA_RECOVERED UnassignedInfo Reason to cont…
Browse files Browse the repository at this point in the history
…rol remote shard recovery

Signed-off-by: bansvaru <bansvaru@amazon.com>
  • Loading branch information
linuxpi committed Oct 17, 2023
1 parent 8bc6791 commit 4650fbb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public Builder initializeAsRemoteStoreRestore(
boolean forceRecoverAllPrimaries
) {
final UnassignedInfo unassignedInfo = new UnassignedInfo(
UnassignedInfo.Reason.EXISTING_INDEX_RESTORED,
UnassignedInfo.Reason.REMOTE_METADATA_RECOVERED,
"restore_source[remote_store]"
);
assert indexMetadata.getIndex().equals(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ public enum Reason {
/**
* Unassigned as a result of closing an index.
*/
INDEX_CLOSED
INDEX_CLOSED,

REMOTE_METADATA_RECOVERED
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.opensearch.cluster.metadata.MappingMetadata;
import org.opensearch.cluster.routing.RecoverySource;
import org.opensearch.cluster.routing.RecoverySource.SnapshotRecoverySource;
import org.opensearch.cluster.routing.UnassignedInfo;
import org.opensearch.common.UUIDs;
import org.opensearch.common.lucene.Lucene;
import org.opensearch.common.unit.TimeValue;
Expand Down Expand Up @@ -434,6 +435,9 @@ private boolean canRecover(IndexShard indexShard) {
// got closed on us, just ignore this recovery
return false;
}
if (indexShard.shardRouting.unassignedInfo().getReason() == UnassignedInfo.Reason.REMOTE_METADATA_RECOVERED) {
return false;
}
if (indexShard.routingEntry().primary() == false) {
throw new IndexShardRecoveryException(shardId, "Trying to recover when the shard is in backup state", null);
}
Expand Down

0 comments on commit 4650fbb

Please sign in to comment.