Skip to content

Always prefer YES over NOT_PREFERRED when allocating unassigned shards#138464

Merged
nicktindall merged 2 commits intoelastic:mainfrom
nicktindall:fix_bug_allocateUnassigned
Nov 24, 2025
Merged

Always prefer YES over NOT_PREFERRED when allocating unassigned shards#138464
nicktindall merged 2 commits intoelastic:mainfrom
nicktindall:fix_bug_allocateUnassigned

Conversation

@nicktindall
Copy link
Contributor

There was a bug when explain was turned off whereby we'd take a NOT_PREFERRED decision over a YES decision if it had a lower weight. This PR removes the problematic optimisation to ensure YES is always preferred regardless of the weights.

@nicktindall nicktindall added >bug :Distributed/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) labels Nov 24, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

@elasticsearchmachine elasticsearchmachine added Team:Distributed Coordination (obsolete) Meta label for Distributed Coordination team. Obsolete. Please do not use. v9.3.0 labels Nov 24, 2025
// YES over THROTTLE/NO/NOT_PREFERRED
assertAssignedTo(allocationService, "yes", shuffledList("not-preferred", "yes", "throttle", "no"));
assertAssignedTo(allocationDeciders, balancingWeightsFactory, "yes", shuffledList("not-preferred", "yes", "throttle", "no"));
assertAssignedTo(allocationDeciders, balancingWeightsFactory, "yes-high", shuffledList("not-preferred-low", "yes-high"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new case triggers the bug.

@elasticsearchmachine
Copy link
Collaborator

Hi @nicktindall, I've created a changelog YAML for you.

AllocationDeciders allocationDeciders,
BalancingWeightsFactory balancingWeightsFactory,
ClusterState clusterState
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to switch over to this approach (removing AllocationService from the test) so that we could randomise the debugMode

@nicktindall nicktindall requested a review from ywangd November 24, 2025 01:06
Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nicktindall nicktindall enabled auto-merge (squash) November 24, 2025 02:10
@nicktindall nicktindall merged commit d222d78 into elastic:main Nov 24, 2025
34 checks passed
@nicktindall nicktindall deleted the fix_bug_allocateUnassigned branch November 24, 2025 04:44
ywangd pushed a commit to ywangd/elasticsearch that referenced this pull request Nov 24, 2025
ncordon pushed a commit to ncordon/elasticsearch that referenced this pull request Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Distributed/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) Team:Distributed Coordination (obsolete) Meta label for Distributed Coordination team. Obsolete. Please do not use. v9.3.0

3 participants