smiklosovic commented on code in PR #4276: URL: https://github.com/apache/cassandra/pull/4276#discussion_r2236487271
########## src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentReader.java: ########## @@ -101,56 +101,69 @@ protected SyncSegment computeNext() { while (true) { + final int currentStart = end; try { - final int currentStart = end; end = readSyncMarker(descriptor, currentStart, reader); - if (end == -1) - { - return endOfData(); - } - if (end > reader.length()) - { - // the CRC was good (meaning it was good when it was written and still looks legit), but the file is truncated now. - // try to grab and use as much of the file as possible, which might be nothing if the end of the file truly is corrupt - end = (int) reader.length(); - } + } + catch (CommitLogSegmentReader.SegmentReadException e) + { + handleUnrecoverableError(e, !e.invalidCrc && tolerateTruncation); + end = -1; // skip the remaining part of the corrupted log segment Review Comment: So just to iterate on the logic here ... when `readSyncMarker` throws `SegmentReadException` and it is evaluated as _permissible_, then `handleUnrecoverableError` will not throw, so `end` will be set to `-1`, hence we will `return endOfData();` later on. If it is thrown and not permissible, we will throw `RuntimeException` from `handleUnrecoverableError`. Then I see that when it is thrown like that, reader is iterated over in `CommitLogReader#readCommitLogSegment`, which is wrapped by try-catch and catches RTE and throws again ... Yeah I think this is legit. -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org