ivandika3 commented on code in PR #1722:
URL: https://github.com/apache/ratis/pull/1722#discussion_r4794789646


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -416,19 +405,23 @@ boolean isApplied() {
     }
 
     this.readIndexType = RaftServerConfigKeys.Read.ReadIndex.type(properties);
+    this.lastReadIndex = readIndexType == Type.COMMIT_INDEX ? null
+        : new RaftLogIndex("lastReadIndex", RaftLog.INVALID_LOG_INDEX);
+    final Supplier<Long> supplier;
     switch (readIndexType) {
     case REPLIED_INDEX:
       this.replyFlusher = new ReplyFlusher(server.getId(), 
state.getLastAppliedIndex(),
           
RaftServerConfigKeys.Read.ReadIndex.repliedIndexBatchInterval(properties));
-      readIndexSupplier = replyFlusher::getRepliedIndex;
+      supplier = replyFlusher::getRepliedIndex;
       break;
     case APPLIED_INDEX:
-      readIndexSupplier = () -> server.getState().getLastAppliedIndex();
+      supplier = () -> server.getState().getLastAppliedIndex();

Review Comment:
   Thanks @szetszwo for catching this. I think the issue is because of the 
wrong ordering in the test state machine implementation, not that it's a Ratis 
bug. The APPLIED_INDEX should not need to fallback to commitIndex. This is good 
since it means the impact is not as large as I thought.
   
   I updated the fix so that it only handles the REPLIED_INDEX, I make 
`lastReadIndex` to use the last appliedIndex instead of commitIndex.



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