Skip to content

Commit

Permalink
Update auto expand replicas
Browse files Browse the repository at this point in the history
This change updates serverless auto expand behaviour when stateless shard allocator is used.
  • Loading branch information
idegtiarenko committed Dec 11, 2024
1 parent d5589d7 commit ff45ad1
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,12 @@ public static Map<Integer, List<String>> getAutoExpandReplicaChanges(
if (autoExpandReplicas.enabled() == false) {
continue;
}
// Special case for stateless indices: auto-expand is disabled, unless number_of_replicas has been set
// manually to 0 via index settings, which needs to be converted to 1.
// Special case for stateless indices: ensures there is always at least one replica.
if (Objects.equals(
indexMetadata.getSettings().get(ExistingShardsAllocator.EXISTING_SHARDS_ALLOCATOR_SETTING.getKey()),
"stateless"
)) {
if (indexMetadata.getNumberOfReplicas() == 0) {
nrReplicasChanged.computeIfAbsent(1, ArrayList::new).add(indexMetadata.getIndex().getName());
} else {
continue;
}
autoExpandReplicas = new AutoExpandReplicas(1, autoExpandReplicas.maxReplicas(), true);
}
if (allocation == null) {
allocation = allocationSupplier.get();
Expand Down

0 comments on commit ff45ad1

Please sign in to comment.