runzhiwang commented on a change in pull request #420:
URL: https://github.com/apache/incubator-ratis/pull/420#discussion_r571376272
##########
File path:
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
##########
@@ -562,17 +562,23 @@ private void installSnapshot(TermIndex
firstAvailableLogTermIndex) {
* @return the first available log's start term index
*/
private TermIndex shouldNotifyToInstallSnapshot() {
- final long leaderStartIndex = getRaftLog().getStartIndex();
Review comment:
change to:
```
private TermIndex shouldNotifyToInstallSnapshot() {
final long leaderStartIndex = getRaftLog().getStartIndex();
if (getFollower().getNextIndex() >= leaderStartIndex) {
return null;
}
// The Leader does not have the logs from the Follower's last log
// index onwards. And install snapshot is disabled. So the Follower
// should be notified to install the latest snapshot through its
// State Machine.
return getRaftLog().getTermIndex(leaderStartIndex);
} else if (leaderStartIndex == RaftLog.INVALID_LOG_INDEX) {
// Leader has no logs to check from, hence return next index.
return TermIndex.valueOf(getServer().getInfo().getCurrentTerm(),
getRaftLog().getNextIndex());
final long followerNextIndex = getFollower().getNextIndex();
final long leaderNextIndex = getRaftLog().getNextIndex();
if (followerNextIndex < leaderNextIndex) {
final long leaderStartIndex = getRaftLog().getStartIndex();
if (followerNextIndex < leaderStartIndex) {
// The Leader does not have the logs from the Follower's last log
// index onwards. And install snapshot is disabled. So the Follower
// should be notified to install the latest snapshot through its
// State Machine.
return getRaftLog().getTermIndex(leaderStartIndex);
} else if (leaderStartIndex == RaftLog.INVALID_LOG_INDEX) {
// Leader has no logs to check from, hence return next index.
return TermIndex.valueOf(getServer().getInfo().getCurrentTerm(),
leaderNextIndex);
}
return null;
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]