hanishakoneru opened a new pull request #100:
URL: https://github.com/apache/incubator-ratis/pull/100


   When an open log segment is loaded, it always logs a warning that the 
segment is corrupted.
   
   ```
   Segment file is corrupted: expected to have -43 entries but only 8 entries 
read successfully
   ```
   LogSegment#loadSegment() has the following check for corruption:
   ```
   final int expectedEntryCount = Math.toIntExact(end - start + 1);
   final boolean corrupted = entryCount != expectedEntryCount;
   if (corrupted) {
     LOG.warn("Segment file is corrupted: expected to have {} entries but only 
{} entries read successfully",
         expectedEntryCount, entryCount);
   }
   ```
   But the end is always INVALID_LOG_INDEX (-1) for an open segment.
   Before this check, entries are appended to the segment. So the end variable 
should be updated with the correct endIndex of the segment before checking for 
corruption.


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