szetszwo commented on code in PR #643:
URL: https://github.com/apache/ratis/pull/643#discussion_r869195343


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/SnapshotInstallationHandler.java:
##########
@@ -206,16 +209,16 @@ private InstallSnapshotReplyProto 
notifyStateMachineToInstallSnapshot(
       state.setLeader(leaderId, "installSnapshot");
       
server.updateLastRpcTime(FollowerState.UpdateType.INSTALL_SNAPSHOT_NOTIFICATION);
 
-      if (inProgressInstallSnapshotIndex.compareAndSet(0, 
firstAvailableLogIndex)) {
+      if (inProgressInstallSnapshotIndex.compareAndSet(INVALID_LOG_INDEX, 
firstAvailableLogIndex)) {
         LOG.info("{}: Received notification to install snapshot at index {}", 
getMemberId(), firstAvailableLogIndex);
         // Check if snapshot index is already at par or ahead of the first
         // available log index of the Leader.
         final long snapshotIndex = state.getLog().getSnapshotIndex();
-        if (snapshotIndex + 1 >= firstAvailableLogIndex && 
firstAvailableLogIndex > 0) {
+        if (snapshotIndex >= firstAvailableLogIndex && firstAvailableLogIndex 
> INVALID_LOG_INDEX) {

Review Comment:
   Yes, ALREADY_INSTALLED is correct.
   
   Leader tells firstAvailableLogIndex (=10) to a follower.   The follower 
checks if it needs to install a snapshot -- if its snapshotIndex < 9, say 
snapshotIndex == 8, there is a gap between snapshotIndex and 
firstAvailableLogIndex so that it needs to install a snapshot with index >= 9.  
The leader is not able to send the index 9 log entry to the follower because 
firstAvailableLogIndex is 10.
   
   If the follower's snapshotIndex == 9, there is no gap so that it can tell 
the leader to send log entires starting at index 10 without installing a 
snapshot.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to