|
11 | 11 | import org.apache.logging.log4j.LogManager;
|
12 | 12 | import org.apache.logging.log4j.Logger;
|
13 | 13 | import org.apache.lucene.util.ArrayUtil;
|
| 14 | +import org.elasticsearch.Version; |
| 15 | +import org.elasticsearch.cluster.metadata.IndexMetadata; |
| 16 | +import org.elasticsearch.cluster.metadata.MetadataIndexStateService; |
14 | 17 | import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata;
|
15 | 18 | import org.elasticsearch.cluster.node.DiscoveryNode;
|
16 | 19 | import org.elasticsearch.cluster.routing.RoutingNode;
|
@@ -95,8 +98,11 @@ private boolean allocateUnassignedInvariant() {
|
95 | 98 |
|
96 | 99 | assert routingNodes.unassigned().isEmpty();
|
97 | 100 |
|
98 |
| - final var shardCounts = allocation.metadata() |
99 |
| - .stream() |
| 101 | + final var shardCounts = allocation.metadata().stream().filter(indexMetadata -> |
| 102 | + // skip any pre-7.2 closed indices which have no routing table entries at all |
| 103 | + indexMetadata.getCreationVersion().onOrAfter(Version.V_7_2_0) |
| 104 | + || indexMetadata.getState() == IndexMetadata.State.OPEN |
| 105 | + || MetadataIndexStateService.isIndexVerifiedBeforeClosed(indexMetadata)) |
100 | 106 | .flatMap(
|
101 | 107 | indexMetadata -> IntStream.range(0, indexMetadata.getNumberOfShards())
|
102 | 108 | .mapToObj(
|
@@ -151,7 +157,7 @@ private void failAllocationOfNewPrimaries(RoutingAllocation allocation) {
|
151 | 157 | private void allocateUnassigned() {
|
152 | 158 | RoutingNodes.UnassignedShards unassigned = routingNodes.unassigned();
|
153 | 159 | if (logger.isTraceEnabled()) {
|
154 |
| - logger.trace("Start allocating unassigned shards"); |
| 160 | + logger.trace("Start allocating unassigned shards: {}", routingNodes.toString()); |
155 | 161 | }
|
156 | 162 | if (unassigned.isEmpty()) {
|
157 | 163 | return;
|
|
0 commit comments