File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
ratis-server/src/main/java/org/apache/ratis/server/impl Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -185,15 +185,19 @@ private InstallSnapshotReplyProto checkAndInstallSnapshot(InstallSnapshotRequest
185185 // considering a follower peer requiring a snapshot installation does not
186186 // have a lot of requests
187187 if (state .getLog ().getLastCommittedIndex () >= lastIncludedIndex ) {
188+ nextChunkIndex .set (snapshotChunkRequest .getRequestIndex () + 1 );
188189 return toInstallSnapshotReplyProto (leaderId , getMemberId (),
189190 currentTerm , snapshotChunkRequest .getRequestIndex (), InstallSnapshotResult .ALREADY_INSTALLED );
190191 }
191192
192193 //TODO: We should only update State with installed snapshot once the request is done.
193194 state .installSnapshot (request );
194195
195- int idx = nextChunkIndex .getAndIncrement ();
196- Preconditions .assertEquals (snapshotChunkRequest .getRequestIndex (), idx , "nextChunkIndex" );
196+ final int expectedChunkIndex = nextChunkIndex .getAndIncrement ();
197+ if (expectedChunkIndex != snapshotChunkRequest .getRequestIndex ()) {
198+ throw new IOException ("Unexpected request chunk index: " + snapshotChunkRequest .getRequestIndex ()
199+ + " (the expected index is " + expectedChunkIndex + ")" );
200+ }
197201 // update the committed index
198202 // re-load the state machine if this is the last chunk
199203 if (snapshotChunkRequest .getDone ()) {
You can’t perform that action at this time.
0 commit comments