Skip to content

Comments

Fix Decision.Type serialization BWC#140199

Merged
nicktindall merged 6 commits intoelastic:mainfrom
nicktindall:fix_decision_type_serialization
Jan 6, 2026
Merged

Fix Decision.Type serialization BWC#140199
nicktindall merged 6 commits intoelastic:mainfrom
nicktindall:fix_decision_type_serialization

Conversation

@nicktindall
Copy link
Contributor

@nicktindall nicktindall commented Jan 6, 2026

Decision.Type order was changed in #137228, but no corresponding change was made serialize it in a BWC manner.

This PR just implements backwardly-compatible serialization for Decision.Type

@nicktindall nicktindall added >bug :Distributed/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) labels Jan 6, 2026
@nicktindall nicktindall marked this pull request as ready for review January 6, 2026 05:38
@elasticsearchmachine elasticsearchmachine added v9.4.0 Team:Distributed Coordination (obsolete) Meta label for Distributed Coordination team. Obsolete. Please do not use. labels Jan 6, 2026
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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

@nicktindall nicktindall added v9.3.1 auto-backport Automatically create backport pull requests when merged labels Jan 6, 2026
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.

The original PR #137228 is labelled as 9.3. Does it mean this PR need backport? The original PR is also being reverted. So I am not sure exactly what status we are in right now?


public void testSerializationBackwardCompatibility() throws IOException {
testReadWriteEnum(YES, YES, ALLOCATION_DECISION_NOT_PREFERRED);
testReadWriteEnum(NOT_PREFERRED, THROTTLE, ALLOCATION_DECISION_NOT_PREFERRED);
Copy link
Member

Choose a reason for hiding this comment

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

I find it a bit confusing and even a slight disturbing to test NOT_PREFERRED is written/read as THROTTLE when the versions do not match. What we really want to ensure is the same enum is preserved across the wire regardless of versions, except NOT_PREFERRED which can be YES for very old versions. Is it possible to more directly test the high level outcome and skip the implementation details?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored in 45a9d5b to be a bit clearer

@nicktindall
Copy link
Contributor Author

The original PR #137228 is labelled as 9.3. Does it mean this PR need backport? The original PR is also being reverted. So I am not sure exactly what status we are in right now?

@ywangd this is in the hope we can avoid reverting the original PR

@ywangd
Copy link
Member

ywangd commented Jan 6, 2026

9.3.0 has not yet released. I think we should raise this and the other PR as a blocker.

@ywangd
Copy link
Member

ywangd commented Jan 6, 2026

If we do release this PR and #140197 as part of 9.3.0, they can be labelled as >non-issue instead of >bug.

@nicktindall nicktindall requested a review from ywangd January 6, 2026 07:31
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

List.of(NO, THROTTLE).forEach(d -> assertFalse(d.assignmentAllowed()));
}

public void testSerializationBackwardCompatibility() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

Can we also test the opposite, i.e. an old enum is written by an old node and deserialized by a new node? Or do you think it's sufficiently covered by the roundTripValue assertions? It's quite similar but the writing side still uses the latest code with conditional branching. I wonder how it compares to writing with the old-style enums unconidtionally?

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 think it is equivalent to what's there by virtue of the fact we assert the old ordinals are written then that they're interpreted correctly when read back by the current enum?

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.

LGTM2

@nicktindall
Copy link
Contributor Author

@elasticsearchmachine test this please

@nicktindall nicktindall enabled auto-merge (squash) January 6, 2026 12:36
@nicktindall nicktindall merged commit a5ab0ca into elastic:main Jan 6, 2026
35 checks passed
@nicktindall nicktindall deleted the fix_decision_type_serialization branch January 6, 2026 12:50
nicktindall added a commit to nicktindall/elasticsearch that referenced this pull request Jan 6, 2026
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >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.1 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants