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 authored Jul 27, 2020
1 parent f238d0a commit 5d8a6bb
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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 @@ -111,9 +112,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 5d8a6bb

Please sign in to comment.