ChenSammi commented on code in PR #561:
URL: https://github.com/apache/ratis/pull/561#discussion_r924495189


##########
ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderBase.java:
##########
@@ -132,17 +136,19 @@ private TermIndex getPrevious(long nextIndex) {
   }
 
   @Override
-  public AppendEntriesRequestProto newAppendEntriesRequest(long callId, 
boolean heartbeat) throws RaftLogIOException {
-    final TermIndex previous = getPrevious(follower.getNextIndex());
-    final long snapshotIndex = follower.getSnapshotIndex();
+  public AppendEntriesRequestProto newAppendEntriesRequest(long callId, 
boolean heartbeat)
+      throws RaftLogIOException {
     final long heartbeatWaitTimeMs = getHeartbeatWaitTimeMs();
+    final TermIndex previous = getPrevious(follower.getNextIndex());
     if (heartbeatWaitTimeMs <= 0L || heartbeat) {
       // heartbeat
-      return leaderState.newAppendEntriesRequestProto(follower, 
Collections.emptyList(), previous, callId);
+      return leaderState.newAppendEntriesRequestProto(follower, 
Collections.emptyList(),
+          hasPendingDataRequests()? null : previous, callId);

Review Comment:
   There is some UT testing the RaftServer pause and resume.  If null is 
returned,the resumed RaftServer will not function well until leader re-election 
happens.  So we need this. 



-- 
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]

Reply via email to