szetszwo commented on a change in pull request #317:
URL: https://github.com/apache/incubator-ratis/pull/317#discussion_r535224658



##########
File path: 
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
##########
@@ -388,10 +388,12 @@ public TermIndex getLastEntryTermIndex() {
     try(AutoCloseableLock writeLock = writeLock()) {
       validateLogEntry(entry);
       final LogSegment currentOpenSegment = cache.getOpenSegment();
+      // The stateMachineData will be cached inside the StateMachine itself 
when enable stateMachineCaching.
+      LogEntryProto toAppendEntry = stateMachineCachingEnabled? 
ServerProtoUtils.removeStateMachineData(entry) : entry;
       if (currentOpenSegment == null) {
         cache.addOpenSegment(entry.getIndex());
         fileLogWorker.startLogSegment(entry.getIndex());
-      } else if (isSegmentFull(currentOpenSegment, entry)) {
+      } else if (isSegmentFull(currentOpenSegment, toAppendEntry)) {

Review comment:
       I see.  It is tricky.  We actually have two sizes, file size and cache 
size, where
   - file size always excludes state machine data, and
   - cache size may or may not include state machine data depending on 
stateMachineCachingEnabled. 
   
   isSegmentFull(..) also has a bug when stateMachineCachingEnabled is false.




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


Reply via email to