-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Simulate shards moved by explicit commands #136066
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
Simulate shards moved by explicit commands #136066
Conversation
In DesiredBalancerComputer, shard movements should be simulated by starting any shards that are initializatng. Previously the explicitly moved shards are not covered. This PR fixes it. Resolves: ES-12943
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
Hi @ywangd, I've created a changelog YAML for you. |
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.
Left some comments.
...main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputer.java
Outdated
Show resolved
Hide resolved
...java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputerTests.java
Show resolved
Hide resolved
...java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputerTests.java
Outdated
Show resolved
Hide resolved
...java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputerTests.java
Show resolved
Hide resolved
...java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputerTests.java
Show resolved
Hide resolved
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.
final ShardRouting[] initializingShards = routingNodes.node( | ||
routingAllocation.nodes().resolveNode(command.toNode()).getId() | ||
).initializing(); | ||
assert initializingShards.length == 1 |
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 assert no initializing shards after the while loop in general? That helps understand this assertion without reading the prior code.
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 is asserted inside BalancedShardAllocator to ensure each simulation call starts without any initialising shad.
routingAllocation.nodes().resolveNode(command.toNode()).getId() | ||
).initializing(); | ||
assert initializingShards.length == 1 | ||
&& routingAllocation.nodes() |
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: let us split into two assertions, one for only 1 initializing shard and one for the right node holding the initializing shard.
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.
Yep see b9dc835
@Override | ||
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { | ||
// Move command works every decision except NO | ||
return randomFrom(Decision.YES, Decision.THROTTLE, Decision.THROTTLE); |
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.
Did you mean not-preferred rather than 2xthrottle?
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.
Should have been not-preferred, updated in 5fbd0f9
var desiredBalanceComputer = createDesiredBalanceComputer(new ShardsAllocator() { | ||
@Override | ||
public void allocate(RoutingAllocation allocation) { | ||
assertThat( |
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.
Perhaps add a comment that this runs right after the moves are applied.
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.
Hmm, perhaps this is actually better as an assertion? Which I sort of proposed above. Happy to keep it though for the test to have verification, but we'll probably hit the assertion first.
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.
Added comment in fcc6449
In BalancedShardsAllocator, we do assert that the initial routingAlloction has no initializing shard. Is it similar to what you have in mind? It's not necessary that allocate
runs "right" after the move commands, e.g. we can have additional code after the move commands. The important thing is that all moving shards are started once computer is ready to call allocate
.
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!
@elasticmachine update branch |
In DesiredBalancerComputer, shard movements should be simulated by starting any shards that are initializatng. Previously the explicitly moved shards are not covered. This PR fixes it.
Resolves: ES-12943