HBASE-18377 Error handling for FileNotFoundException should consider RemoteException in openReader()

This commit is contained in:
tedyu 2017-07-18 06:46:34 -07:00
parent 80959b4528
commit a74d270f7f
1 changed files with 15 additions and 7 deletions

View File

@ -41,6 +41,7 @@ import org.apache.hadoop.hbase.util.LeaseNotRecoveredException;
import org.apache.hadoop.hbase.wal.WAL.Entry; import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.wal.WAL.Reader; import org.apache.hadoop.hbase.wal.WAL.Reader;
import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALFactory;
import org.apache.hadoop.ipc.RemoteException;
/** /**
* Streaming access to WAL entries. This class is given a queue of WAL {@link Path}, and continually * Streaming access to WAL entries. This class is given a queue of WAL {@link Path}, and continually
@ -316,6 +317,15 @@ public class WALEntryStream implements Iterator<Entry>, Closeable, Iterable<Entr
} }
} }
private void handleFileNotFound(Path path, FileNotFoundException fnfe) throws IOException {
// If the log was archived, continue reading from there
Path archivedLog = getArchivedLog(path);
if (!path.equals(archivedLog)) {
openReader(archivedLog);
} else {
throw fnfe;
}
}
private void openReader(Path path) throws IOException { private void openReader(Path path) throws IOException {
try { try {
// Detect if this is a new file, if so get a new reader else // Detect if this is a new file, if so get a new reader else
@ -329,13 +339,11 @@ public class WALEntryStream implements Iterator<Entry>, Closeable, Iterable<Entr
resetReader(); resetReader();
} }
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
// If the log was archived, continue reading from there handleFileNotFound(path, fnfe);
Path archivedLog = getArchivedLog(path); } catch (RemoteException re) {
if (!path.equals(archivedLog)) { IOException ioe = re.unwrapRemoteException(FileNotFoundException.class);
openReader(archivedLog); if (!(ioe instanceof FileNotFoundException)) throw ioe;
} else { handleFileNotFound(path, (FileNotFoundException)ioe);
throw fnfe;
}
} catch (LeaseNotRecoveredException lnre) { } catch (LeaseNotRecoveredException lnre) {
// HBASE-15019 the WAL was not closed due to some hiccup. // HBASE-15019 the WAL was not closed due to some hiccup.
LOG.warn("Try to recover the WAL lease " + currentPath, lnre); LOG.warn("Try to recover the WAL lease " + currentPath, lnre);