Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Enhance AllocationService to allocate unassigned shards in batches #8959

Open
amkhar opened this issue Jul 28, 2023 · 0 comments
Assignees
Labels
bug Something isn't working Cluster Manager

Comments

@amkhar
Copy link
Contributor

amkhar commented Jul 28, 2023

Describe the bug
Original Issue opened : #5098 . This issue is a sub task for the overall project defined #8098.

Description
As part of node drop and joins, AllocationService takes care of allocating all primary and replica unassigned shards one by one.

private void allocateExistingUnassignedShards(RoutingAllocation allocation) {
allocation.routingNodes().unassigned().sort(PriorityComparator.getAllocationComparator(allocation)); // sort for priority ordering
for (final ExistingShardsAllocator existingShardsAllocator : existingShardsAllocators.values()) {
existingShardsAllocator.beforeAllocation(allocation);
}
final RoutingNodes.UnassignedShards.UnassignedIterator primaryIterator = allocation.routingNodes().unassigned().iterator();
while (primaryIterator.hasNext()) {
final ShardRouting shardRouting = primaryIterator.next();
if (shardRouting.primary()) {
getAllocatorForShard(shardRouting, allocation).allocateUnassigned(shardRouting, allocation, primaryIterator);
}
}
for (final ExistingShardsAllocator existingShardsAllocator : existingShardsAllocators.values()) {
existingShardsAllocator.afterPrimariesBeforeReplicas(allocation);
}
final RoutingNodes.UnassignedShards.UnassignedIterator replicaIterator = allocation.routingNodes().unassigned().iterator();
while (replicaIterator.hasNext()) {
final ShardRouting shardRouting = replicaIterator.next();
if (shardRouting.primary() == false) {
getAllocatorForShard(shardRouting, allocation).allocateUnassigned(shardRouting, allocation, replicaIterator);
}
}
}

This allocation of shards requires fetching metadata from all data nodes. As we're moving towards fetching metadata of batch of shards in one transport call, AllocationService needs to send all the shards to the Allocator in one go (using ExistingShardsAllocator interface). So, that allocator can create batches and takes care of fetching of metadata on a batch level.

Functionalities required:

  • Add new method in ExistingShardsAllocator (backward compatible, and non-breaking)
  • Call newly added method from AllocationService
  • Handle backward compatibility, unless all nodes of the cluster has support for batching, keep using older mechanism of shard level fetch and allocation.

Additional context
Please go through the discussion #5098 to understand the overall enhancement approach and check #8098 to see the sub tasks of overall project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Cluster Manager
Projects
Status: Now(This Quarter)
Development

No branches or pull requests

2 participants