Xushaohong commented on code in PR #745:
URL: https://github.com/apache/ratis/pull/745#discussion_r969510543
##########
ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderBase.java:
##########
@@ -158,6 +158,11 @@ private TermIndex getPrevious(long nextIndex) {
}
}
+ final long raftLogLastPurgedIndex = getRaftLog().getStartIndex() - 1;
+ if (raftLogLastPurgedIndex == previousIndex) {
+ return TermIndex.valueOf(server.getInfo().getCurrentTerm(),
raftLogLastPurgedIndex);
Review Comment:
> We should check term-begin-index.
Thx @szetszwo for the reply, but I have some doubts about the patch:
` if (nextIndex > beginIndex) {
return TermIndex.valueOf(currentTerm, previousIndex);
} else if (nextIndex == beginIndex) {
return TermIndex.valueOf(currentTerm - 1, previousIndex);
}`
1. Is the log Index monotonic increasing?
2. In the logic of `checkInconsistentAppendEntries`, the term is also vital
for consistency. Here only considers the case to decrease the current term by
one, but the reality is that the term could have a gap. Besides that, the new
leader may not know the term when the follower takes a snapshot, it only gets
the follower's snapshot index now.
--
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]