Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,10 @@ public PersistentTasksCustomMetadata.Assignment getAssignment(

/**
* Only shards that can be searched can be used as the source of a downsampling task.
* In stateless deployment, this means that shards that CANNOT be promoted to primary can be used.
* For simplicity, in non-stateless deployments we use the primary shard.
*/
private boolean isEligible(ShardRouting shardRouting) {
return shardRouting.started() && (isStateless ? shardRouting.isPromotableToPrimary() == false : shardRouting.primary());
return shardRouting.started() && (isStateless ? shardRouting.isSearchable() : shardRouting.primary());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In stateless, this would return false in indexing tier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the code I checked, this is determined based on the role of the shard, for example, an indexing shard is not searchable while a search shard is.

I think this should be sufficient, given that we trust that the searchable shard is assigned to the searching tier. In the end, downsampling needs a shard that can be searched, where that shard is allocated is a consequence of this, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right and I think in case of stateless this is true.

}

private boolean isCandidateNode(Collection<DiscoveryNode> candidateNodes, String nodeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,14 @@ public void testGetStatelessAssignment() {
var searchNode = newNode(Set.of(DiscoveryNodeRole.SEARCH_ROLE));
var indexNode = newNode(Set.of(DiscoveryNodeRole.INDEX_ROLE));
var shardId = new ShardId(backingIndex, 0);
ShardRouting indexOnlyShard = shardRoutingBuilder(shardId, indexNode.getId(), true, STARTED).withRecoverySource(null)
.withRole(ShardRouting.Role.INDEX_ONLY)
.build();
var clusterState = ClusterState.builder(initialClusterState)
.nodes(new DiscoveryNodes.Builder().add(indexNode).add(searchNode).build())
.putRoutingTable(
projectId,
RoutingTable.builder()
.add(
IndexRoutingTable.builder(backingIndex)
.addShard(shardRoutingBuilder(shardId, indexNode.getId(), true, STARTED).withRecoverySource(null).build())
)
.build()
RoutingTable.builder().add(IndexRoutingTable.builder(backingIndex).addShard(indexOnlyShard)).build()
)
.build();

Expand All @@ -177,7 +175,7 @@ public void testGetStatelessAssignment() {
RoutingTable.builder()
.add(
IndexRoutingTable.builder(backingIndex)
.addShard(shardRoutingBuilder(shardId, indexNode.getId(), true, STARTED).withRecoverySource(null).build())
.addShard(indexOnlyShard)
.addShard(
shardRoutingBuilder(shardId, searchNode.getId(), false, STARTED).withRecoverySource(null)
.withRole(ShardRouting.Role.SEARCH_ONLY)
Expand Down