You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2020/12/22 03:23:46 UTC

[incubator-ratis] branch master updated: RATIS-1241. Leader unable to append logs to a recovering follower when its logs have been purged. (#360)

This is an automated email from the ASF dual-hosted git repository.

szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ddf0db  RATIS-1241. Leader unable to append logs to a recovering follower when its logs have been purged. (#360)
2ddf0db is described below

commit 2ddf0dbb27f78727d5b93546445d2112e5612e15
Author: avijayanhwx <14...@users.noreply.github.com>
AuthorDate: Mon Dec 21 19:23:08 2020 -0800

    RATIS-1241. Leader unable to append logs to a recovering follower when its logs have been purged. (#360)
---
 .../src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java  | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
index eee13f2..1c8e4ea 100644
--- a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
+++ b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
@@ -28,6 +28,7 @@ import org.apache.ratis.server.leader.FollowerInfo;
 import org.apache.ratis.server.leader.LeaderState;
 import org.apache.ratis.server.leader.LogAppenderBase;
 import org.apache.ratis.server.protocol.TermIndex;
+import org.apache.ratis.server.raftlog.RaftLog;
 import org.apache.ratis.server.util.ServerStringUtils;
 import org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver;
 import org.apache.ratis.proto.RaftProtos.AppendEntriesReplyProto;
@@ -568,6 +569,10 @@ public class GrpcLogAppender extends LogAppenderBase {
       // 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());
     }
     return null;
   }