[
https://issues.apache.org/jira/browse/RATIS-1902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17774625#comment-17774625
]
Tsz-wo Sze commented on RATIS-1902:
-----------------------------------
RATIS-1883 triggered this bug:
# The Leader send a install snapshot notification to a Follower.
# When the log is empty and there is no snapshots, the Follower tries to reply
snapshot index RaftLog.INVALID_LOG_INDEX (== -1).
# However, this bug changes the snapshot index from -1 to 0.
# The Leader will set unconditionally the match index to the snapshot index
(== 0) and the next index to (match index + 1) = 1.
# The Leader uses the next index (== 1) to send appendEntries, i.e. the index
of the first entry is 1.
# Since the follower does not have the index 0 log entry, it replies
INCONSISTENCY with reply.nextIndex == 0.
# Here is the problem:
** Before RATIS-1883, the Leader will set its next index to reply.nextIndex
(== 0) and fix the problem.
** After RATIS-1883, the Leader will set its next index to max(matchIndex+1,
reply.nextIndex) == 1. The problem repeats indefinitely.
> The snapshot index is set incorrectly in InstallSnapshotReplyProto
> ------------------------------------------------------------------
>
> Key: RATIS-1902
> URL: https://issues.apache.org/jira/browse/RATIS-1902
> Project: Ratis
> Issue Type: Bug
> Components: server
> Reporter: Tsz-wo Sze
> Assignee: Tsz-wo Sze
> Priority: Major
>
> {code}
> // ServerProtoUtils.java
> static InstallSnapshotReplyProto toInstallSnapshotReplyProto(
> RaftPeerId requestorId, RaftGroupMemberId replyId,
> long currentTerm, InstallSnapshotResult result, long
> installedSnapshotIndex) {
> final RaftRpcReplyProto.Builder rb =
> toRaftRpcReplyProtoBuilder(requestorId,
> replyId, isSuccess(result));
> final InstallSnapshotReplyProto.Builder builder =
> InstallSnapshotReplyProto
>
> .newBuilder().setServerReply(rb).setTerm(currentTerm).setResult(result);
> if (installedSnapshotIndex > 0) {
> builder.setSnapshotIndex(installedSnapshotIndex);
> }
> return builder.build();
> }
> {code}
> In the code above, the condition installedSnapshotIndex > 0 above is invalid
> since it cannot be set to RaftLog.INVALID_LOG_INDEX (== -1). When the log is
> empty and there is no snapshots, it is correct for a follower replying
> RaftLog.INVALID_LOG_INDEX.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)