hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1178625 - in /hbase/branches/0.92: ./ src/main/java/org/apache/hadoop/hbase/regionserver/ src/test/java/org/apache/hadoop/hbase/regionserver/
Date Mon, 03 Oct 2011 22:51:36 GMT
Author: tedyu
Date: Mon Oct  3 22:51:35 2011
New Revision: 1178625

URL: http://svn.apache.org/viewvc?rev=1178625&view=rev
Log:
HBASE-4334 HRegion.get never validates row (Lars H)

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1178625&r1=1178624&r2=1178625&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Mon Oct  3 22:51:35 2011
@@ -319,6 +319,7 @@ Release 0.92.0 - Unreleased
    HBASE-4496  HFile V2 does not honor setCacheBlocks when scanning (Lars and Mikhail)
    HBASE-4531  hbase-4454 failsafe broke mvn site; back it out or fix
                (Akash Ashok)
+   HBASE-4334 HRegion.get never validates row (Lars Hofhansl)
 
   TESTS
    HBASE-4492  TestRollingRestart fails intermittently

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1178625&r1=1178624&r2=1178625&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Mon
Oct  3 22:51:35 2011
@@ -1335,7 +1335,8 @@ public class HRegion implements HeapSize
     }
   }
 
-  protected RegionScanner getScanner(Scan scan, List<KeyValueScanner> additionalScanners)
throws IOException {
+  protected RegionScanner getScanner(Scan scan,
+      List<KeyValueScanner> additionalScanners) throws IOException {
     startRegionOperation();
     this.readRequestsCount.increment();
     try {
@@ -1347,7 +1348,6 @@ public class HRegion implements HeapSize
         }
       }
       return instantiateRegionScanner(scan, additionalScanners);
-
     } finally {
       closeRegionOperation();
     }
@@ -2427,10 +2427,10 @@ public class HRegion implements HeapSize
   //////////////////////////////////////////////////////////////////////////////
 
   /** Make sure this is a valid row for the HRegion */
-  private void checkRow(final byte [] row, String op) throws IOException {
+  void checkRow(final byte [] row, String op) throws IOException {
     if(!rowIsInRange(regionInfo, row)) {
       throw new WrongRegionException("Requested row out of range for " +
-          op + "on HRegion " + this + ", startKey='" +
+          op + " on HRegion " + this + ", startKey='" +
           Bytes.toStringBinary(regionInfo.getStartKey()) + "', getEndKey()='" +
           Bytes.toStringBinary(regionInfo.getEndKey()) + "', row='" +
           Bytes.toStringBinary(row) + "'");
@@ -3369,6 +3369,7 @@ public class HRegion implements HeapSize
    * @throws IOException read exceptions
    */
   public Result get(final Get get, final Integer lockid) throws IOException {
+    checkRow(get.getRow(), "Get");
     // Verify families are all valid
     if (get.hasFamilies()) {
       for (byte [] family: get.familySet()) {

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1178625&r1=1178624&r2=1178625&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Mon Oct  3 22:51:35 2011
@@ -2014,6 +2014,7 @@ public class HRegionServer implements HR
     requestCount.incrementAndGet();
     try {
       HRegion r = getRegion(regionName);
+      r.checkRow(scan.getStartRow(), "Scan");
       r.prepareScanner(scan);
       RegionScanner s = null;
       if (r.getCoprocessorHost() != null) {

Modified: hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1178625&r1=1178624&r2=1178625&view=diff
==============================================================================
--- hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
(original)
+++ hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Mon Oct  3 22:51:35 2011
@@ -2792,6 +2792,24 @@ public class TestHRegion extends HBaseTe
     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
+    }
+    byte[] row = Bytes.toBytes("y");
+    g = new Get(row);
+    region.get(g, null);
+  }
 
   public void testIndexesScanWithOneDeletedRow() throws IOException {
     byte[] tableName = Bytes.toBytes("testIndexesScanWithOneDeletedRow");
@@ -3142,13 +3160,19 @@ public class TestHRegion extends HBaseTe
   }
 
   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)) {



Mime
View raw message