- Notifications
You must be signed in to change notification settings - Fork 25.6k
Take into account expectedShardSize when initializing shard in simulation #95734
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
Take into account expectedShardSize when initializing shard in simulation #95734
Conversation
| 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.
LGTM
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.
nit: I guess there's no need for a max here since the caller ignores negative values.
| return Math.max(0L, shard.getExpectedShardSize()); | |
| return shard.getExpectedShardSize(); |
…sage This change asserts that produced balance does not utilize all disk space.
eaca950 to 5aeb4d9 Compare | if (replicaNodeId != null) { | ||
| dataPath.put(new NodeAndShard(replicaNodeId, shardId), "/data"); | ||
| usedDiskSpace.compute(primaryNodeId, (k, v) -> v + thisShardSize); | ||
| usedDiskSpace.compute(replicaNodeId, (k, v) -> v + thisShardSize); |
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 was causing some of the assertions failing
| Hi @idegtiarenko, I've created a changelog YAML for you. |
| var deviation = randomIntBetween(0, 50) - 100L; | ||
| return originalSize * (1000 + deviation) / 1000; | ||
| var deviation = randomIntBetween(0, 10) - 5; | ||
| return originalSize * (100 + deviation) / 100; |
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.
Previously this was only producing shards that are 5-10% smaller then original size, while this should generate -5..+5%
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 still. I think there were only really test changes here, but you force-pushed so I can't see the diffs.
| private static long smallShardSizeDeviation(long originalSize) { | ||
| var deviation = randomIntBetween(0, 50) - 100L; | ||
| return originalSize * (1000 + deviation) / 1000; | ||
| var deviation = randomIntBetween(0, 10) - 5; |
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.
nit/suggestion:
| var deviation = randomIntBetween(0, 10) - 5; | |
| var deviation = randomIntBetween(-5, 5); |
or maybe even drop the 100 + and do this:
| var deviation = randomIntBetween(0, 10) - 5; | |
| var deviation = randomIntBetween(95, 105); |
This change takes into account expectedShardSize when simulating new shard initialization during desired balance computation.
This should reduce balance movements when restoring a shard from snapshot as it has known size beforehand.