Index: src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java (revision 1157283) +++ src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java (working copy) @@ -42,7 +42,7 @@ private ResultScanner scanner = null; private Scan scan = null; private HTable htable = null; - private byte[] lastRow = null; + private byte[] lastSuccessfulRow = null; private ImmutableBytesWritable key = null; private Result value = null; @@ -132,20 +132,23 @@ value = this.scanner.next(); } catch (IOException e) { LOG.debug("recovered from " + StringUtils.stringifyException(e)); - if (lastRow == null) { + if (lastSuccessfulRow == null) { LOG.warn("We are restarting the first next() invocation," + " if your mapper's restarted a few other times like this" + " then you should consider killing this job and investigate" + " why it's taking so long."); - lastRow = scan.getStartRow(); } - restart(lastRow); - scanner.next(); // skip presumed already mapped row + if (lastSuccessfulRow == null) { + restart(scan.getStartRow()); + } else { + restart(lastSuccessfulRow); + scanner.next(); // skip presumed already mapped row + } value = scanner.next(); } if (value != null && value.size() > 0) { key.set(value.getRow()); - lastRow = key.get(); + lastSuccessfulRow = key.get(); return true; } return false; Index: src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java (revision 1157283) +++ src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java (working copy) @@ -44,7 +44,7 @@ private byte [] startRow; private byte [] endRow; - private byte [] lastRow; + private byte [] lastSuccessfulRow; private Filter trrRowFilter; private ResultScanner scanner; private HTable htable; @@ -175,16 +175,26 @@ Result result; try { result = this.scanner.next(); - } catch (UnknownScannerException e) { + } catch (IOException e) { LOG.debug("recovered from " + StringUtils.stringifyException(e)); - restart(lastRow); - this.scanner.next(); // skip presumed already mapped row + if (lastSuccessfulRow == null) { + LOG.warn("We are restarting the first next() invocation," + + " if your mapper's restarted a few other times like this" + + " then you should consider killing this job and investigate" + + " why it's taking so long."); + } + if (lastSuccessfulRow == null) { + restart(startRow); + } else { + restart(lastSuccessfulRow); + this.scanner.next(); // skip presumed already mapped row + } result = this.scanner.next(); } if (result != null && result.size() > 0) { key.set(result.getRow()); - lastRow = key.get(); + lastSuccessfulRow = key.get(); Writables.copyWritable(result, value); return true; }