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

RATIS-2166. Update nextChunkIndex when snapshot is ALREADY_INSTALLED #1159

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

133tosakarin
Copy link
Contributor

@133tosakarin 133tosakarin commented Sep 30, 2024

What changes were proposed in this pull request?

Fix legacy problems with #1145

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/RATIS-2166

@133tosakarin
Copy link
Contributor Author

@szetszwo
These failed tests seem to meet expectations

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

@szetszwo
Copy link
Contributor

szetszwo commented Oct 8, 2024

@133tosakarin , on a second thought, let's change the Preconditions.assertEquals(..) to throw IOException. Preconditions usually is for correctness checking. If Preconditions fails, it should indicate a bug.

@@ -192,8 +193,12 @@ class SnapshotInstallationHandler {
         //TODO: We should only update State with installed snapshot once the request is done.
         state.installSnapshot(request);
 
-        int idx = nextChunkIndex.getAndIncrement();
-        Preconditions.assertEquals(snapshotChunkRequest.getRequestIndex(), idx, "nextChunkIndex");
+        final int expectedChunkIndex = nextChunkIndex.getAndIncrement();
+        if (snapshotChunkRequest.getRequestIndex() != expectedChunkIndex) {
+          throw new IOException("Unexpected request chunk index: " + snapshotChunkRequest.getRequestIndex()
+              + " (the expected index is " + expectedChunkIndex + ")");
+        }
+
         // update the committed index
         // re-load the state machine if this is the last chunk

@szetszwo szetszwo changed the title RATIS-2166. Regarding the follow-up patch issue of RATIS-2148 RATIS-2166. Update nextChunkIndex when snapshot is ALREADY_INSTALLED Oct 9, 2024
@133tosakarin 133tosakarin reopened this Oct 9, 2024
Copy link
Contributor

@OneSizeFitsQuorum OneSizeFitsQuorum left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

@133tosakarin , thanks of the update!

@szetszwo
Copy link
Contributor

szetszwo commented Oct 9, 2024

@133tosakarin , you are right that the failures does not seem related; see #1156 . Let's merge this without further retries.

@szetszwo szetszwo merged commit 09f6b39 into apache:master Oct 9, 2024
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants