[ 
https://issues.apache.org/jira/browse/RATIS-937?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hanisha Koneru resolved RATIS-937.
----------------------------------
    Resolution: Fixed

> Loading of open segments always throws corrupted segment warning
> ----------------------------------------------------------------
>
>                 Key: RATIS-937
>                 URL: https://issues.apache.org/jira/browse/RATIS-937
>             Project: Ratis
>          Issue Type: Bug
>            Reporter: Hanisha Koneru
>            Assignee: Hanisha Koneru
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> When an open log segment is loaded, it always logs a warning that the segment 
> is corrupted.
> {code:java}
> Segment file is corrupted: expected to have -43 entries but only 8 entries 
> read successfully
> {code}
> LogSegment#loadSegment() has the following check for corruption:
> {code:java}
> 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);
> }
> {code}
> 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 message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to