Index: src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (revision 1177893) +++ src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (working copy) @@ -2792,6 +2792,33 @@ flushThread.checkNoError(); } + public void testHolesInMeta() throws Exception { + String method = "testHolesInMeta"; + byte[] tableName = Bytes.toBytes(method); + byte[] family = Bytes.toBytes("family"); + initHRegion(tableName, Bytes.toBytes("x"), Bytes.toBytes("z"), method, + HBaseConfiguration.create(), family); + byte[] rowNotServed = Bytes.toBytes("a"); + Get g = new Get(rowNotServed); + try { + region.get(g, null); + fail(); + } catch (WrongRegionException x) { + // OK + } + Scan s = new Scan(rowNotServed); + try { + region.getScanner(s); + fail(); + } catch (WrongRegionException x) { + // OK + } + byte[] row = Bytes.toBytes("y"); + g = new Get(row); + s = new Scan(row); + region.get(g, null); + region.getScanner(s); + } public void testIndexesScanWithOneDeletedRow() throws IOException { byte[] tableName = Bytes.toBytes("testIndexesScanWithOneDeletedRow"); @@ -3093,6 +3120,7 @@ throws IOException { byte [][] families = {fs}; Scan scan = new Scan(); + scan.setStartRow(r.getStartKey()); for (int i = 0; i < families.length; i++) scan.addFamily(families[i]); InternalScanner s = r.getScanner(scan); try { @@ -3142,13 +3170,19 @@ } private void initHRegion (byte [] tableName, String callingMethod, - Configuration conf, byte [] ... families) - throws IOException{ + Configuration conf, byte [] ... families) + throws IOException{ + initHRegion(tableName, null, null, callingMethod, conf, families); + } + + private void initHRegion(byte[] tableName, byte[] startKey, byte[] stopKey, + String callingMethod, Configuration conf, byte[]... families) + throws IOException { HTableDescriptor htd = new HTableDescriptor(tableName); for(byte [] family : families) { htd.addFamily(new HColumnDescriptor(family)); } - HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false); + HRegionInfo info = new HRegionInfo(htd.getName(), startKey, stopKey, false); Path path = new Path(DIR + callingMethod); if (fs.exists(path)) { if (!fs.delete(path, true)) { Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 1177893) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -1335,9 +1335,11 @@ } } - protected RegionScanner getScanner(Scan scan, List additionalScanners) throws IOException { + protected RegionScanner getScanner(Scan scan, + List additionalScanners) throws IOException { startRegionOperation(); this.readRequestsCount.increment(); + checkRow(scan.getStartRow(), "Get/Scan"); try { // Verify families are all valid prepareScanner(scan); @@ -1347,7 +1349,6 @@ } } return instantiateRegionScanner(scan, additionalScanners); - } finally { closeRegionOperation(); }