-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Clamp auto-expand replicas to the closest value #87505
Conversation
Hi @pxsalehi, I've created a changelog YAML for you. |
@elasticmachine update branch |
Ensure that the number of replicas chosen for an auto-expand-able shard is within the range of the available data nodes, i.e., excluding those nodes that cannot be assigned a replica. Closes elastic#84788
11e398e
to
1c1b9ea
Compare
server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java
Show resolved
Hide resolved
Pinging @elastic/es-distributed (Team:Distributed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments, otherwise this looks good.
equalTo(String.valueOf(initialReplicas)) | ||
); | ||
}); | ||
ensureGreen(indexName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unimportant to the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, at least for the sake of making it clear what the test expects, we should leave it here. Removing it didn't seem to really speedup the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not about test speed. But waiting for green here signals that it is important to the test. But the test will pass without this, since our auto-expand calculation is independent of the status of the index. Hence I think we should simply remove it.
}); | ||
|
||
ensureGreen(indexName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also remove the setting and see that it jumps back to the initialReplicas
value, thus checking that it clamps to the higher bound too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ec7d7f9.
|
||
// Package private only for testing purposes! | ||
int calculateDesiredNumberOfReplicas(int numMatchingDataNodes) { | ||
final int min = minReplicas(); | ||
final int max = getMaxReplicas(numMatchingDataNodes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Math.min
done in getMaxReplicas
seems redundant now, I think we should remove it, it is somewhat confusing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good point! It also simplifies the code and the parsing test. Done in ec7d7f9.
server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java
Show resolved
Hide resolved
@@ -282,4 +282,16 @@ public void testOnlyAutoExpandAllocationFilteringAfterAllNodesUpgraded() { | |||
terminate(threadPool); | |||
} | |||
} | |||
|
|||
public void testCalculateDesiredNumberOfReplicas() { | |||
String settingValue = randomFrom("0-all", "0-3"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we explore the space a bit more here, for instance by choosing both lower and upper bound randomly like:
int lowerBound = between(0,9);
int upperBound = between(lowerBound, 10);
String settingValue = lowerBound + "-" + upperBound;
Having a dedicated test (or random variation) with "all" also makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ec7d7f9.
...er/src/internalClusterTest/java/org/elasticsearch/cluster/metadata/AutoExpandReplicasIT.java
Outdated
Show resolved
Hide resolved
…pandReplicas.java Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
…metadata/AutoExpandReplicasIT.java Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
@elasticmachine update branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, provided tests pass
equalTo(String.valueOf(initialReplicas)) | ||
); | ||
}); | ||
ensureGreen(indexName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not about test speed. But waiting for green here signals that it is important to the test. But the test will pass without this, since our auto-expand calculation is independent of the status of the index. Hence I think we should simply remove it.
Thanks Henning! If index status is irrelevant here, then I agree with you. I removed them! :-) |
Ensure that the number of replicas chosen for an auto-expand-able index
is within the range of the available data nodes, i.e., excluding those
nodes that cannot be assigned a replica.
Closes #84788