Skip to content

[8.4] Autoscaling after clone fix (#89768) #89786

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

Merged
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions docs/changelog/89768.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 89768
summary: Autoscaling after clone fix
area: Autoscaling
type: bug
issues:
- 89758
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ public void testScaleWhileShrinking() throws Exception {
setTotalSpace(dataNode1Name, tooLittleSpaceForShrink + 1);
assertAcked(client().admin().cluster().prepareReroute());
ensureGreen();

client().admin().indices().prepareDelete(indexName).get();
response = capacity();
assertThat(
response.results().get(policyName).requiredCapacity().total().storage(),
equalTo(response.results().get(policyName).currentCapacity().total().storage())
);
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/88478")
Expand Down Expand Up @@ -481,6 +488,13 @@ public void testScaleDuringSplitOrClone() throws Exception {
setTotalSpace(dataNode1Name, requiredSpaceForClone);
assertAcked(client().admin().cluster().prepareReroute());
ensureGreen();

client().admin().indices().prepareDelete(indexName).get();
response = capacity();
assertThat(
response.results().get(policyName).requiredCapacity().total().storage().getBytes(),
equalTo(requiredSpaceForClone + enoughSpace)
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,20 +487,22 @@ private long nodeLockedSize(IndexMetadata indexMetadata, Metadata metadata) {
} else {
Index resizeSourceIndex = indexMetadata.getResizeSourceIndex();
if (resizeSourceIndex != null) {
IndexMetadata sourceIndexMetadata = metadata.getIndexSafe(resizeSourceIndex);
// ResizeAllocationDecider only handles clone or split, do the same here.

if (indexMetadata.getNumberOfShards() >= sourceIndexMetadata.getNumberOfShards()) {
IndexRoutingTable indexRoutingTable = state.getRoutingTable().index(resizeSourceIndex);
long max = 0;
for (int s = 0; s < sourceIndexMetadata.getNumberOfShards(); ++s) {
ShardRouting shard = indexRoutingTable.shard(s).primaryShard();
long size = sizeOf(shard);
max = Math.max(max, size);
IndexMetadata sourceIndexMetadata = metadata.index(resizeSourceIndex);
// source indicators stay on the index even after started and also after source is deleted.
if (sourceIndexMetadata != null) {
// ResizeAllocationDecider only handles clone or split, do the same here.
if (indexMetadata.getNumberOfShards() >= sourceIndexMetadata.getNumberOfShards()) {
IndexRoutingTable indexRoutingTable = state.getRoutingTable().index(resizeSourceIndex);
long max = 0;
for (int s = 0; s < sourceIndexMetadata.getNumberOfShards(); ++s) {
ShardRouting shard = indexRoutingTable.shard(s).primaryShard();
long size = sizeOf(shard);
max = Math.max(max, size);
}

// 2x to account for the extra copy residing on the same node
return max * 2;
}

// 2x to account for the extra copy residing on the same node
return max * 2;
}
}
}
Expand Down