Skip to content

Commit

Permalink
Relax ShardFollowTasksExecutor validation (#60054)
Browse files Browse the repository at this point in the history
If a primary shard of a follower index is being relocated, then we
will fail to create a follow-task. This validation is too restricted.
We should ensure that all primaries of the follower index are active
instead.

Closes #59625
  • Loading branch information
dnhatn committed Aug 11, 2020
1 parent c4ff608 commit 104fff2
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.CheckedConsumer;
import org.elasticsearch.common.settings.IndexScopedSettings;
Expand Down Expand Up @@ -112,9 +113,10 @@ public ShardFollowTasksExecutor(Client client,

@Override
public void validate(ShardFollowTask params, ClusterState clusterState) {
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(params.getFollowShardId().getIndex());
if (routingTable.shard(params.getFollowShardId().id()).primaryShard().started() == false) {
throw new IllegalArgumentException("Not all copies of follow shard are started");
final IndexRoutingTable routingTable = clusterState.getRoutingTable().index(params.getFollowShardId().getIndex());
final ShardRouting primaryShard = routingTable.shard(params.getFollowShardId().id()).primaryShard();
if (primaryShard.active() == false) {
throw new IllegalArgumentException("The primary shard of a follower index " + primaryShard + " is not active");
}
}

Expand Down

0 comments on commit 104fff2

Please sign in to comment.