hanishakoneru commented on pull request #170:
URL: https://github.com/apache/incubator-ratis/pull/170#issuecomment-673673687


   Consider the following scenario.
   Snapshot is taken every 25 transactions. PurgeUptoSnapshotIndex is set to 
false. This implies when snapshot is taken, only logs up to min commit index on 
all nodes will be purged.
   Now let's say we have log segments _log_11_20_, _log_21_30_ and _log_31_40_ 
on disk. Snapshot was taken at index 25 but one of the nodes had commit index 
12. So only _log_0_10_ is purged. When this node is restarted, it will not add 
_log_11_20_ to its closedSegments because of the following logic in 
_SegmentedRaftLogCache_. When purge is called next, _log_11_20_ will not be 
purged as it is not in the cached closedSegments list. 
   
   ```
   void loadSegment(LogPathAndIndex pi, boolean keepEntryInCache,
         Consumer<LogEntryProto> logConsumer, long lastIndexInSnapshot) throws 
IOException {
       LogSegment logSegment = LogSegment.loadSegment(storage, 
pi.getPath().toFile(),
           pi.getStartIndex(), pi.getEndIndex(), pi.isOpen(), keepEntryInCache, 
logConsumer, raftLogMetrics);
       if (logSegment != null && logSegment.getEndIndex() > 
lastIndexInSnapshot) {
         addSegment(logSegment);
       }
     }
   ```


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