Skip to content

Conversation

@mhl-b
Copy link
Contributor

@mhl-b mhl-b commented Aug 19, 2025

This PR adds new Enum variant for Decision.Type - NOT_PREFERRED, along with existing NO, THROTTLE, and YES. NOT_PREFERRED is intended for the WriteLoadDecider to indicate not preferable but possible allocations. It's a soft NO. Also changes wire format to enum ordinals.

ES-11998

@mhl-b mhl-b force-pushed the decision-not-preferred branch from 373d328 to b40821a Compare August 20, 2025 19:11
@mhl-b mhl-b marked this pull request as ready for review August 20, 2025 20:23
@mhl-b mhl-b added :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) Team:Distributed Coordination Meta label for Distributed Coordination team labels Aug 20, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Contributor

@nicktindall nicktindall left a comment

Choose a reason for hiding this comment

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

This seems pragmatic to me.

Am I right in thinking we chose "soft yes" rather than "soft no" because it was more aligned with existing interpretations of YES/NO? because what we're saying from the WriteLoadConstraintDecider feels more like a soft no than a soft yes to me.

I wonder if the distinction between a soft no and a soft yes will be important one day, or they'll both mean effectively the same thing (i.e. MAYBE).

@mhl-b
Copy link
Contributor Author

mhl-b commented Aug 21, 2025

I wonder if the distinction between a soft no and a soft yes will be important one day, or they'll both mean effectively the same thing (i.e. MAYBE).

I'm dont think boolean Preferred will last. My personal opinion is that we need some number value attached to YES, a decision confidence. Especially for non-binary deciders(sounds funny in modern world), like resource based where we have shades of grey rather than clean yes/no. Also not-preferred is a relative term, it serves when only not-preferred options left and we need to choose best one. So this relativity means we need a comparison between decisions, hence some ordering, right?

For example:

  • Awareness and MaxRetry are binary deciders and can return NO or YES-100%.
  • Resource related deciders can return NO when above some absolute high threshold, and YES-10% when we are reaching limit. Then we can compare Decisions during canAllocate phase and choose best node.

@mhl-b
Copy link
Contributor Author

mhl-b commented Aug 21, 2025

Am I right in thinking we chose "soft yes" rather than "soft no" because it was more aligned with existing interpretations of YES/NO? because what we're saying from the WriteLoadConstraintDecider feels more like a soft no than a soft yes to me.

Are you asking about WriteLoadConstraintDecider changes in PR, like this Decision.preferred(NAME, "canRemain() is not enabled"); and return just YES?
If thats the question, then there is no particular reason for using preferred here, just to distinguish between YES and YES_NOT_PREFERRED.

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

I find the preferred dimension unnecessary, let us keep this one-dimensional.


Single ALWAYS = new Single(Type.YES);
Single YES = new Single(Type.YES);
Single YES_NOT_PREFERRED = new Single(Type.YES, Preferred.NO);
Copy link
Contributor

@henningandersen henningandersen Aug 21, 2025

Choose a reason for hiding this comment

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

I'd prefer a new Type.NOT_PREFERRED, just to keep it simple and not have multi-dimensions here. We can evolve ofc, but starting simple seems ... well simpler. We do not need the other variants of this. And NO not preferred, throttle not preferred etc. does not seem relevant.

This Decision would then also be named NOT_PREFERRED, no need for YES in the name, it is a decision between No and Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to a single dimension.

@mhl-b mhl-b force-pushed the decision-not-preferred branch from 67cbd43 to 1dbdc7b Compare August 23, 2025 00:42
@mhl-b mhl-b changed the title Add yes-not-preferred allocation decision Add not-preferred allocation decision Aug 23, 2025
Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

LGTM.

public static AllocationDecision fromDecisionType(Decision.Type type) {
return switch (type) {
case YES -> YES;
case YES, NOT_PREFERRED -> YES;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add a todo here, preferably with a JIRA number attached. We need to figure out what to do. Perfectly fine to defer.

Copy link
Contributor

@nicktindall nicktindall left a comment

Choose a reason for hiding this comment

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

LGTM

@mhl-b mhl-b merged commit 83c1b52 into elastic:main Aug 25, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants