Skip to content
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

[Bug] Update logic on CheckpointState around serialization/deserialization #5809

Merged

Conversation

dreamer-89
Copy link
Member

@dreamer-89 dreamer-89 commented Jan 10, 2023

Description

As part of #5282, we introduced a boolean flag in CheckpointState inside ReplicationTracker with incorrect serialization/deserialization logic.

The bwc tests (using on CheckpointState for transport communication e.g. RecoveryHandoffPrimaryContextRequest) fails on 2.x because of in.getVersion().onOrAfter(Version.CURRENT) (2.5.0) < Version.Current (2.6.0); resulting in else block execution thereby skipping read on boolean. BUT, the write to outputstream is unconditional which means the minor version (2.5.0 containing #5282 change) writes to output stream.

The correct fix here is:

  1. Replace Version.CURRENT with specific version. Version.CURRENT is unreliable as it changes with branch and difficult to argue about in code
  2. Update output stream write to be conditional so that it writes only when it is supported.
if (in.getVersion().onOrAfter(Version.V_2_5_0)) {
    this.replicated = in.readBoolean();
} else {
    this.replicated = true;
}

Issues Resolved

#5801
#5766

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Suraj Singh <surajrider@gmail.com>
@dreamer-89 dreamer-89 changed the title [Bug] Update logic on CheckpointState around searial/deserial [Bug] Update logic on CheckpointState around serialization/deserialization Jan 10, 2023
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@mch2 mch2 merged commit eeca443 into opensearch-project:main Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants