[
https://issues.apache.org/jira/browse/RATIS-1902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tsz-wo Sze updated RATIS-1902:
------------------------------
Description:
{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.
was:
{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 correct
since it cannot be set to RaftLog.INVALID_LOG_INDEX (== -1).
> 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)