HBASE-4196 TableRecordReader may skip first row of region

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1157324 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-08-13 05:21:38 +00:00
parent 738f80c221
commit 20aef0eaf7
3 changed files with 25 additions and 11 deletions

View File

@ -433,6 +433,7 @@ Release 0.90.5 - Unreleased
or server includes binary-encoded data (Jonathan Hsieh)
HBASE-4168 A client continues to try and connect to a powered down
regionserver (Anirudh Todi)
HBASE-4196 TableRecordReader may skip first row of region (Ming Ma)
Release 0.90.4 - August 10, 2011

View File

@ -44,7 +44,7 @@ public class TableRecordReaderImpl {
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 @@ public class TableRecordReaderImpl {
Result result;
try {
result = this.scanner.next();
} catch (UnknownScannerException e) {
} catch (IOException e) {
LOG.debug("recovered from " + StringUtils.stringifyException(e));
restart(lastRow);
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;
}

View File

@ -42,7 +42,7 @@ public class TableRecordReaderImpl {
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 @@ public class TableRecordReaderImpl {
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);
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;