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

Skip ancient closed indices in desired balance #91765

Merged
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 @@ -11,6 +11,9 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.ArrayUtil;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.MetadataIndexStateService;
import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.RoutingNode;
Expand Down Expand Up @@ -95,8 +98,11 @@ private boolean allocateUnassignedInvariant() {

assert routingNodes.unassigned().isEmpty();

final var shardCounts = allocation.metadata()
.stream()
final var shardCounts = allocation.metadata().stream().filter(indexMetadata ->
// skip any pre-7.2 closed indices which have no routing table entries at all
indexMetadata.getCreationVersion().onOrAfter(Version.V_7_2_0)
|| indexMetadata.getState() == IndexMetadata.State.OPEN
|| MetadataIndexStateService.isIndexVerifiedBeforeClosed(indexMetadata))
.flatMap(
indexMetadata -> IntStream.range(0, indexMetadata.getNumberOfShards())
.mapToObj(
Expand Down Expand Up @@ -151,7 +157,7 @@ private void failAllocationOfNewPrimaries(RoutingAllocation allocation) {
private void allocateUnassigned() {
RoutingNodes.UnassignedShards unassigned = routingNodes.unassigned();
if (logger.isTraceEnabled()) {
logger.trace("Start allocating unassigned shards");
logger.trace("Start allocating unassigned shards: {}", routingNodes.toString());
}
if (unassigned.isEmpty()) {
return;
Expand Down