Skip to content

Commit

Permalink
clean up max shards logic
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <marc.handalian@gmail.com>
  • Loading branch information
mch2 committed Dec 10, 2024
1 parent 48ca1a3 commit e600a6f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ private IndexMetadata.Builder updateInSyncAllocations(
// We use number_of_replicas + 1 (= possible active shard copies) to bound the inSyncAllocationIds set
// Only trim the set of allocation ids when it grows, otherwise we might trim too eagerly when the number
// of replicas was decreased while shards were unassigned.
int maxActiveShards = oldIndexMetadata.getNumberOfReplicas() + oldIndexMetadata.getNumberOfSearchOnlyReplicas() + 1; // +1 for
// the
// primary
int maxActiveShards = oldIndexMetadata.getNumberOfReplicas() + 1; // +1 for
// the
// primary
IndexShardRoutingTable newShardRoutingTable = newRoutingTable.shardRoutingTable(shardId);
assert newShardRoutingTable.assignedShards()
.stream()
Expand All @@ -277,6 +277,7 @@ private IndexMetadata.Builder updateInSyncAllocations(
List<ShardRouting> assignedShards = newShardRoutingTable.assignedShards()
.stream()
.filter(s -> s.isRelocationTarget() == false)
.filter(s -> s.isSearchOnly() == false) // do not consider search only shards for in sync validation
.collect(Collectors.toList());
assert assignedShards.size() <= maxActiveShards : "cannot have more assigned shards "
+ assignedShards
Expand Down

0 comments on commit e600a6f

Please sign in to comment.