netudima commented on code in PR #4276:
URL: https://github.com/apache/cassandra/pull/4276#discussion_r2237343676


##########
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:
   yes, the essential change is adding end = -1 to move to the end of the 
corrupted segment, previously when we ignored an error we started to read the 
corrupted place again from the same place, so it was an infinite loop. 
   handleUnrecoverableError contains the existing logic, I've just moved the 
repeating logic into an utility method to make the main loop logic more clear.
   



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

Reply via email to