Index: src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (revision 1177872) +++ src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (working copy) @@ -2792,6 +2792,32 @@ 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"); @@ -3142,13 +3168,19 @@ } private void initHRegion (byte [] tableName, String callingMethod, + 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 1177872) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -1335,9 +1335,15 @@ } } - protected RegionScanner getScanner(Scan scan, List additionalScanners) throws IOException { + protected RegionScanner getScanner(Scan scan, + List additionalScanners) throws IOException { startRegionOperation(); this.readRequestsCount.increment(); + // start row can be empty in tests, so allow for that + byte[] startRow = scan.getStartRow(); + if (startRow != null && !Bytes.equals(startRow, HConstants.EMPTY_START_ROW)) { + checkRow(startRow, "Get/Scan"); + } try { // Verify families are all valid prepareScanner(scan); @@ -1347,7 +1353,6 @@ } } return instantiateRegionScanner(scan, additionalScanners); - } finally { closeRegionOperation(); }