Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Service does not start on Windows with OpenJDK ([#20615](https://github.com/opensearch-project/OpenSearch/pull/20615))
- Update RemoteClusterStateCleanupManager to performed batched deletions of stale ClusterMetadataManifests and address deletion timeout issues ([#20566](https://github.com/opensearch-project/OpenSearch/pull/20566))
- Fix the regression of terms agg optimization at high cardinality ([#20623](https://github.com/opensearch-project/OpenSearch/pull/20623))
- Fix Shard routings for closed index are allocated again without opening the index ([#20648](https://github.com/opensearch-project/OpenSearch/pull/20648))
- Leveraging segment-global ordinal mapping for efficient terms aggregation ([#20624](https://github.com/opensearch-project/OpenSearch/pull/20624))
- Support Docker distribution builds for ppc64le, arm64 and s390x ([#20678](https://github.com/opensearch-project/OpenSearch/pull/20678))
- Harden detection of HTTP/3 support by ensuring Quic native libraries are available for the target platform ([#20680](https://github.com/opensearch-project/OpenSearch/pull/20680))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,4 +956,11 @@ public boolean unassignedReasonIndexCreated() {
}
return false;
}

public boolean isClosedIndexShard() {
if (unassigned() && unassignedInfo != null) {
return unassignedInfo.getReason() == UnassignedInfo.Reason.INDEX_CLOSED;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ protected static void innerAllocatedUnassigned(
ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler
) {
assert shardRouting.unassigned();
// Skip allocation for closed index shards
if (shardRouting.isClosedIndexShard()) {
return;
}
if (shardRouting.primary()) {
primaryShardAllocator.allocateUnassigned(shardRouting, allocation, unassignedAllocationHandler);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ protected Set<String> createAndUpdateBatches(RoutingAllocation allocation, boole
Set<ShardId> batchedShardsToAssign = Sets.newHashSet();
// add all unassigned shards to the batch if they are not already in a batch
unassigned.forEach(shardRouting -> {
// Skip allocation for closed index shards - for new shards and already-batched shards whose index subsequently closed
if (shardRouting.isClosedIndexShard()) {
return;
}
if ((currentBatchedShards.containsKey(shardRouting.shardId()) == false) && (shardRouting.primary() == primary)) {
assert shardRouting.unassigned();
newShardsToBatch.put(shardRouting.shardId(), shardRouting);
Comment thread
srikanthpadakanti marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,44 @@ public void testSwapPrimaryWithReplica() {
assertFalse(activeReplicaShard1.primary());
}

public void testIsClosedIndexShard() {
ShardRouting closedShard = TestShardRouting.newShardRouting(
"test",
0,
null,
null,
false,
ShardRoutingState.UNASSIGNED,
new UnassignedInfo(UnassignedInfo.Reason.INDEX_CLOSED, "index closed")
);
assertTrue(closedShard.isClosedIndexShard());

ShardRouting createdShard = TestShardRouting.newShardRouting(
"test",
0,
null,
null,
false,
ShardRoutingState.UNASSIGNED,
new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "index created")
);
assertFalse(createdShard.isClosedIndexShard());

ShardRouting startedShard = TestShardRouting.newShardRouting("test", 0, "node1", true, ShardRoutingState.STARTED);
assertFalse(startedShard.isClosedIndexShard());

ShardRouting initializingShard = TestShardRouting.newShardRouting(
"test",
0,
"node1",
null,
false,
ShardRoutingState.INITIALIZING,
new UnassignedInfo(UnassignedInfo.Reason.INDEX_CLOSED, "index closed")
);
assertFalse(initializingShard.isClosedIndexShard());
}

public void testExpectedSize() throws IOException {
final int iters = randomIntBetween(10, 100);
for (int i = 0; i < iters; i++) {
Expand Down
Loading
Loading