HBASE-14168 Avoid useless retry for DoNotRetryIOException in TableRecordReaderImpl (zhouyingchao)

This commit is contained in:
tedyu 2015-07-31 09:23:17 -07:00
parent f1f0d99662
commit 11d7beed64
4 changed files with 25 additions and 19 deletions

View File

@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.ScannerCallable;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableInputFormat;
@ -213,7 +214,11 @@ public class TableRecordReaderImpl {
}
}
} catch (IOException e) {
// try to handle all IOExceptions by restarting
// do not retry if the exception tells us not to do so
if (e instanceof DoNotRetryIOException) {
throw e;
}
// try to handle all other IOExceptions by restarting
// the scanner, if the second call fails, it will be rethrown
LOG.debug("recovered from " + StringUtils.stringifyException(e));
if (lastSuccessfulRow == null) {

View File

@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.ScannerCallable;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.metrics.ScanMetrics;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.mapreduce.Counter;
@ -215,7 +216,11 @@ public class TableRecordReaderImpl {
}
}
} catch (IOException e) {
// try to handle all IOExceptions by restarting
// do not retry if the exception tells us not to do so
if (e instanceof DoNotRetryIOException) {
throw e;
}
// try to handle all other IOExceptions by restarting
// the scanner, if the second call fails, it will be rethrown
LOG.info("recovered from " + StringUtils.stringifyException(e));
if (lastSuccessfulRow == null) {

View File

@ -243,9 +243,9 @@ public class TestTableInputFormat {
doReturn("bogus".getBytes()).when(scan).getStartRow(); // avoid npe
ResultScanner scanner = mock(ResultScanner.class);
invocation.callRealMethod(); // simulate UnknownScannerException
invocation.callRealMethod(); // simulate NotServingRegionException
doThrow(
new UnknownScannerException("Injected simulated TimeoutException"))
new NotServingRegionException("Injected simulated TimeoutException"))
.when(scanner).next();
return scanner;
}
@ -294,8 +294,7 @@ public class TestTableInputFormat {
}
/**
* Run test assuming UnknownScannerException (which is a type of
* DoNotRetryIOException) using mapred api.
* Run test assuming NotServingRegionException using mapred api.
*
* @throws org.apache.hadoop.hbase.DoNotRetryIOException
*/
@ -306,12 +305,11 @@ public class TestTableInputFormat {
}
/**
* Run test assuming UnknownScannerException (which is a type of
* DoNotRetryIOException) using mapred api.
* Run test assuming NotServingRegionException using mapred api.
*
* @throws org.apache.hadoop.hbase.DoNotRetryIOException
*/
@Test(expected = org.apache.hadoop.hbase.DoNotRetryIOException.class)
@Test(expected = org.apache.hadoop.hbase.NotServingRegionException.class)
public void testTableRecordReaderScannerTimeoutTwice() throws IOException {
Table htable = createDNRIOEScannerTable("table5".getBytes(), 2);
runTestMapred(htable);

View File

@ -227,8 +227,8 @@ public class TestTableInputFormat {
}
/**
* Create a table that throws a DoNoRetryIOException on first scanner next
* call
* Create a table that throws a NotServingRegionException on first scanner
* next call
*
* @throws IOException
*/
@ -247,9 +247,9 @@ public class TestTableInputFormat {
doReturn("bogus".getBytes()).when(scan).getStartRow(); // avoid npe
ResultScanner scanner = mock(ResultScanner.class);
invocation.callRealMethod(); // simulate UnknownScannerException
invocation.callRealMethod(); // simulate NotServingRegionException
doThrow(
new UnknownScannerException("Injected simulated TimeoutException"))
new NotServingRegionException("Injected simulated TimeoutException"))
.when(scanner).next();
return scanner;
}
@ -304,8 +304,7 @@ public class TestTableInputFormat {
}
/**
* Run test assuming UnknownScannerException (which is a type of
* DoNotRetryIOException) using newer mapreduce api
* Run test assuming NotServingRegionException using newer mapreduce api
*
* @throws InterruptedException
* @throws org.apache.hadoop.hbase.DoNotRetryIOException
@ -318,13 +317,12 @@ public class TestTableInputFormat {
}
/**
* Run test assuming UnknownScannerException (which is a type of
* DoNotRetryIOException) using newer mapreduce api
* Run test assuming NotServingRegionException using newer mapreduce api
*
* @throws InterruptedException
* @throws org.apache.hadoop.hbase.DoNotRetryIOException
* @throws org.apache.hadoop.hbase.NotServingRegionException
*/
@Test(expected = org.apache.hadoop.hbase.DoNotRetryIOException.class)
@Test(expected = org.apache.hadoop.hbase.NotServingRegionException.class)
public void testTableRecordReaderScannerTimeoutMapreduceTwice()
throws IOException, InterruptedException {
Table htable = createDNRIOEScannerTable("table5-mr".getBytes(), 2);