adoroszlai commented on code in PR #643:
URL: https://github.com/apache/ratis/pull/643#discussion_r869175948
##########
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:
Do I understand correctly that `snapshotIndex` is the last index in a
snapshot that follower already installed, and `firstAvailableLogIndex` is the
first index available from leader that would be part of a new snapshot if
follower requested?
If so, assume `snapshotIndex = 9` and `firstAvailableLogIndex = 10`. In
this case 9+1 >= 10, hence follower responds with `ALREADY_INSTALLED`. Does
that seem right?
--
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]