hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1534365 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/regionserver/HRegion.java test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Date Mon, 21 Oct 2013 20:31:47 GMT
Author: larsh
Date: Mon Oct 21 20:31:47 2013
New Revision: 1534365

URL: http://svn.apache.org/r1534365
Log:
HBASE-9783 o.a.h.h.r.HRegion.mutateRow() with non-existent CF cause NPE (Aditya Kishore)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1534365&r1=1534364&r2=1534365&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Mon
Oct 21 20:31:47 2013
@@ -4923,6 +4923,7 @@ public class HRegion implements HeapSize
 
       long txid = 0;
       boolean walSyncSuccessful = false;
+      boolean memstoreUpdated = false;
       boolean locked = false;
 
       // 2. acquire the row lock(s)
@@ -4982,6 +4983,7 @@ public class HRegion implements HeapSize
 
         // 7. apply to memstore
         long addedSize = 0;
+        memstoreUpdated = true;
         for (Mutation m : mutations) {
           addedSize += applyFamilyMapToMemstore(m.getFamilyMap(), w);
         }
@@ -5021,7 +5023,7 @@ public class HRegion implements HeapSize
         }
       } finally {
         // 12. clean up if needed
-        if (!walSyncSuccessful) {
+        if (memstoreUpdated && !walSyncSuccessful) {
           int kvsRolledback = 0;
           for (Mutation m : mutations) {
             for (Map.Entry<byte[], List<KeyValue>> e : m.getFamilyMap()

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1534365&r1=1534364&r2=1534365&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Mon Oct 21 20:31:47 2013
@@ -63,6 +63,7 @@ import org.apache.hadoop.hbase.client.HT
 import org.apache.hadoop.hbase.client.Increment;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.RowMutations;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.filter.BinaryComparator;
 import org.apache.hadoop.hbase.filter.ColumnCountGetFilter;
@@ -1013,6 +1014,26 @@ public class TestHRegion extends HBaseTe
     }
   }
 
+  public void testmutateRowsWithLocks_wrongCF() throws IOException {
+    this.region = initHRegion(tableName, this.getName(), conf, fam1, fam2);
+    try {
+      Put put = new Put(row2);
+      put.add(fam3, qual1, value1);
+      RowMutations rm = new RowMutations(row2);
+      rm.add(put);
+      try {
+        region.mutateRow(rm);
+        fail();
+      } catch (DoNotRetryIOException expected) {
+        // expected exception.
+        LOG.debug("Caught expected exception: " + expected.getMessage());
+      }
+    } finally {
+      HRegion.closeHRegion(this.region);
+      this.region = null;
+    }
+  }
+  
   public void testCheckAndDelete_ThatDeleteWasWritten() throws IOException{
     byte [] tableName = Bytes.toBytes("testtable");
     byte [] row1 = Bytes.toBytes("row1");



Mime
View raw message