diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 40205c4..1cb350c 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -344,7 +344,9 @@ public class HRegion implements HeapSize { // , Writable{ minSeqId = storeSeqId; } } - // Recover any edits if available. + // Recover any edits if available. The returned seqid is the maximum found + // in the logs whether we applied the edit or not (it will be -1 if no + // edits in logs). long seqid = replayRecoveredEditsIfAny(this.regiondir, minSeqId, reporter); // Get rid of any splits or merges that were lost in-progress. Clean out @@ -1860,8 +1862,8 @@ public class HRegion implements HeapSize { // , Writable{ * @param minSeqId Minimum sequenceid found in a store file. Edits in log * must be larger than this to be replayed. * @param reporter - * @return the sequence id of the last edit added to this region out of the - * recovered edits log, or -1 if no log recovered + * @return the sequence id of the last edit in the WAL whether or not we + * added the edit to this region, or -1 if no edits in the log. * @throws UnsupportedEncodingException * @throws IOException */ @@ -1885,8 +1887,12 @@ public class HRegion implements HeapSize { // , Writable{ System.currentTimeMillis()); LOG.error("hbase.skip.errors=true so continuing. Renamed " + edits + " as " + moveAsideName, e); - if (!this.fs.rename(edits, moveAsideName)) { - LOG.error("hbase.skip.errors=true so continuing. Rename failed"); + try { + if (!this.fs.rename(edits, moveAsideName)) { + LOG.error("hbase.skip.errors=true so continuing. Rename failed"); + } + } catch (Exception ee) { + LOG.error("hbase.skip.errors=true so continuing", ee); } } else { throw e; @@ -1900,8 +1906,8 @@ public class HRegion implements HeapSize { // , Writable{ * @param minSeqId Minimum sequenceid found in a store file. Edits in log * must be larger than this to be replayed. * @param reporter - * @return the sequence id of the last edit added to this region out of the - * recovered edits log, or -1 if no log recovered + * @return the sequence id of the last edit in the WAL whether or not we + * added the edit to this region, or -1 if no edits in the log. * @throws IOException */ private long replayRecoveredEdits(final Path edits, @@ -1919,8 +1925,8 @@ public class HRegion implements HeapSize { // , Writable{ * @param minSeqId Minimum sequenceid found in a store file. Edits in log * must be larger than this to be replayed. * @param reporter - * @return the sequence id of the last edit added to this region out of the - * recovered edits log, or -1 if no log recovered + * @return the sequence id of the last edit in the WAL whether or not we + * added the edit to this region, or -1 if no edits in the log. * @throws IOException */ private long replayRecoveredEdits(final HLog.Reader reader, @@ -1931,13 +1937,16 @@ public class HRegion implements HeapSize { // , Writable{ long skippedEdits = 0; long editsCount = 0; HLog.Entry entry; + boolean skipErrors = conf.getBoolean("hbase.skip.errors", false); Store store = null; // Get map of family name to maximum sequence id. Do it here up front // because as we progress, the sequence id can change if we happen to flush // The flush ups the seqid for the Store. The new seqid can cause us skip edits. Map familyToOriginalMaxSeqId = familyToMaxSeqId(this.stores); - // How many edits to apply before we send a progress report. - int interval = this.conf.getInt("hbase.hstore.report.interval.edits", 2000); + // How long to wait before we send a progress report. + long interval = this.conf.getInt("hbase.hstore.report.interval.edits.ms", + 10000); + long lastReport = System.currentTimeMillis(); while ((entry = reader.next()) != null) { HLogKey key = entry.getKey(); WALEdit val = entry.getEdit(); @@ -1963,6 +1972,10 @@ public class HRegion implements HeapSize { // , Writable{ store = this.stores.get(kv.getFamily()); } if (store == null) { + if (!skipErrors) { + throw new NoSuchColumnFamilyException("No Store for kv=" + + kv.getKeyString()); + } // This should never happen. Perhaps schema was changed between // crash and redeploy? LOG.warn("No family for " + kv); @@ -1978,12 +1991,16 @@ public class HRegion implements HeapSize { // , Writable{ } restoreEdit(kv); editsCount++; - } + } - // Every 'interval' edits, tell the reporter we're making progress. - // Have seen 60k edits taking 3minutes to complete. - if (reporter != null && (editsCount % interval) == 0) { - reporter.progress(); + // Every 'interval' edits, tell the reporter we're making progress. Don't + // call System.currentTimeMillis for every edit. + if (reporter != null && (editsCount % 10) == 0) { + long now = System.currentTimeMillis(); + if (now - lastReport > interval) { + reporter.progress(); + lastReport = now; + } } } if (LOG.isDebugEnabled()) {