-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix SnapshotStats toXContent()/fromXContent() round trip serialization #128928
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
Merged
JeremyDahlgren
merged 10 commits into
elastic:main
from
JeremyDahlgren:fix/snapshotstats-fromxcontent
Jun 6, 2025
Merged
Fix SnapshotStats toXContent()/fromXContent() round trip serialization #128928
JeremyDahlgren
merged 10 commits into
elastic:main
from
JeremyDahlgren:fix/snapshotstats-fromxcontent
Jun 6, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toXContent() has a check to omit the "processed" sub-object if the processedFileCount equals the incrementalFileCount. In the scenario where they are equal and greater than zero, if you were to read the JSON back in with fromXContent(), the SnapshotStats object would not be the same as the original since processedFileCount is not parsed and set. This change adds a fix and a unit test for this scenario.
Hi @JeremyDahlgren, I've created a changelog YAML for you. |
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
DaveCTurner
reviewed
Jun 5, 2025
test/framework/src/main/java/org/elasticsearch/test/AbstractXContentTestCase.java
Outdated
Show resolved
Hide resolved
DaveCTurner
approved these changes
Jun 5, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore
Anything directly related to the `_snapshot/*` APIs
Team:Distributed Coordination
Meta label for Distributed Coordination team
>test
Issues or PRs that are addressing/adding tests
v9.1.0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
toXContent()
has a check to omit the "processed" sub-object if theprocessedFileCount
equals theincrementalFileCount
. In the scenario where they are equal and greater than zero, if you were to read the JSON back in withfromXContent()
, theSnapshotStats
object would not be the same as the original sinceprocessedFileCount
is not parsed and set. You can breakSnapshotStatsTests
by forcingcreateTestInstance()
to pass theincrementalFileCount
value forprocessedFileCount
when constructing the instance. This PR adds a fix and increases the probability of creating this scenario increateTestInstance()
.Since
fromXContent()
is no longer called from production code, this PR also movesSnapshotStats.fromXContent()
intoSnapshotStatsTests
.For context, #29602 is the PR for reviewing when
getProcessedFileCount() != getIncrementalFileCount()
was added inSnapshotStats.toXContent()
, and #31515 is the PR for reviewing whenSnapshotStats.fromXContent()
was added.This issue was found while working on tests for #128399 and noticing
XContent
round trip serialization was not working as expected.