Skip to content

Commit a51cdcc

Browse files
authored
CNDB-16352: filterCommitLogFiles handles NoSuchFileException gracefully (#2186)
### What is the issue FSReadError extends IOError, so it was not caught by the catch block in filterCommitLogFiles(). This caused replayer failures when a remote commit log file was listed but no longer accessible. ### What does this PR fix and why was it fixed Only NoSuchFileException is handled gracefully; other IOErrors (such as corruption) are re-thrown to fail the replay as intended.
1 parent e9afd3a commit a51cdcc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/java/org/apache/cassandra/db/commitlog/CommitLogReader.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package org.apache.cassandra.db.commitlog;
1919

20+
import java.io.IOError;
2021
import java.nio.file.Files;
2122
import java.nio.file.Path;
2223
import java.io.*;
@@ -119,6 +120,19 @@ static List<File> filterCommitLogFiles(File[] toFilter)
119120
// let recover deal with it
120121
filtered.add(file);
121122
}
123+
catch (IOError e)
124+
{
125+
// Only handle file-not-found errors gracefully; let other IOErrors propagate
126+
// as they may indicate corruption or serious I/O issues
127+
if (e.getCause() instanceof java.nio.file.NoSuchFileException)
128+
{
129+
filtered.add(file);
130+
}
131+
else
132+
{
133+
throw e;
134+
}
135+
}
122136
}
123137

124138
return filtered;

0 commit comments

Comments
 (0)