HBASE-2933 Skip EOF Errors during Log Recovery

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1023183 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-10-16 05:27:57 +00:00
parent 0f27ee880c
commit 63ba21eca5
2 changed files with 69 additions and 64 deletions

View File

@ -586,6 +586,8 @@ Release 0.21.0 - Unreleased
HBASE-3044 [replication] ReplicationSource won't cleanup logs if there's
nothing to replicate
HBASE-3113 Don't reassign regions if cluster is being shutdown
HBASE-2933 Skip EOF Errors during Log Recovery
(Nicolas Spiegelberg via Stack)
IMPROVEMENTS

View File

@ -19,6 +19,7 @@
*/
package org.apache.hadoop.hbase.regionserver;
import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
@ -1807,29 +1808,14 @@ public class HRegion implements HeapSize { // , Writable{
LOG.info("Replaying edits from " + edits + "; minSequenceid=" + minSeqId);
HLog.Reader reader = HLog.getReader(this.fs, edits, conf);
try {
return replayRecoveredEdits(reader, minSeqId, reporter);
} finally {
reader.close();
}
}
/* @param reader Reader against file of recovered edits.
* @param minSeqId Any edit found in split editlogs needs to be in excess of
* this minSeqId to be applied, else its skipped.
* @param reporter
* @return the sequence id of the last edit added to this region out of the
* recovered edits log or <code>minSeqId</code> if nothing added from editlogs.
* @throws IOException
*/
private long replayRecoveredEdits(final HLog.Reader reader,
final long minSeqId, final Progressable reporter)
throws IOException {
long currentEditSeqId = minSeqId;
long firstSeqIdInLog = -1;
long skippedEdits = 0;
long editsCount = 0;
HLog.Entry entry;
Store store = null;
try {
// How many edits to apply before we send a progress report.
int interval = this.conf.getInt("hbase.hstore.report.interval.edits", 2000);
while ((entry = reader.next()) != null) {
@ -1878,12 +1864,29 @@ public class HRegion implements HeapSize { // , Writable{
reporter.progress();
}
}
} catch (EOFException eof) {
Path p = HLog.moveAsideBadEditsFile(fs, edits);
LOG.warn("Encountered EOF. Most likely due to Master failure during " +
"log spliting, so we have this data in another edit. " +
"Continuing, but renaming " + edits + " as " + p, eof);
} catch (IOException ioe) {
if (ioe.getMessage().startsWith("File is corrupt")) {
Path p = HLog.moveAsideBadEditsFile(fs, edits);
LOG.warn("File corruption encountered! " +
"Continuing, but renaming " + edits + " as " + p, ioe);
} else {
throw ioe;
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Applied " + editsCount + ", skipped " + skippedEdits +
", firstSequenceidInLog=" + firstSeqIdInLog +
", maxSequenceidInLog=" + currentEditSeqId);
}
return currentEditSeqId;
} finally {
reader.close();
}
}
/**