You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2017/01/23 17:30:48 UTC

hbase git commit: HBASE-17510 DefaultMemStore gets the wrong heap size after rollback (ChiaPing Tsai)

Repository: hbase
Updated Branches:
  refs/heads/branch-1 6e0f3f5bb -> 50ecbf1c8


HBASE-17510 DefaultMemStore gets the wrong heap size after rollback (ChiaPing Tsai)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/50ecbf1c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/50ecbf1c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/50ecbf1c

Branch: refs/heads/branch-1
Commit: 50ecbf1c8a9d57a43c043a01bb76d4eef2cce739
Parents: 6e0f3f5
Author: tedyu <yu...@gmail.com>
Authored: Mon Jan 23 09:30:39 2017 -0800
Committer: tedyu <yu...@gmail.com>
Committed: Mon Jan 23 09:30:39 2017 -0800

----------------------------------------------------------------------
 .../hbase/regionserver/DefaultMemStore.java     |  4 ++--
 .../hadoop/hbase/regionserver/TestStore.java    | 24 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/50ecbf1c/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultMemStore.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultMemStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultMemStore.java
index 8412d6e..a47cafd 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultMemStore.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultMemStore.java
@@ -347,8 +347,8 @@ public class DefaultMemStore implements MemStore {
     // If the key is in the memstore, delete it. Update this.size.
     found = this.cellSet.get(cell);
     if (found != null && found.getSequenceId() == cell.getSequenceId()) {
-      removeFromCellSet(cell);
-      long s = heapSizeChange(cell, true);
+      removeFromCellSet(found);
+      long s = heapSizeChange(found, true);
       this.size.addAndGet(-s);
     }
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/50ecbf1c/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java
index 414c663..5b7f8e8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java
@@ -90,6 +90,7 @@ import org.junit.rules.TestName;
 import org.mockito.Mockito;
 
 import com.google.common.collect.Lists;
+import java.util.Arrays;
 
 /**
  * Test class for the Store
@@ -359,6 +360,29 @@ public class TestStore {
   }
 
   @Test
+  public void testRollback() throws IOException {
+    Configuration conf = HBaseConfiguration.create();
+    FileSystem fs = FileSystem.get(conf);
+    // Initialize region
+    init(name.getMethodName(), conf);
+    Cell cell = CellUtil.createCell(row, family, qf1);
+    int len = KeyValueUtil.length(cell);
+    int offset = 77;
+    byte[] buf = new byte[offset + len];
+    KeyValueUtil.appendToByteArray(cell, buf, offset);
+    KeyValue newKv = new KeyValue(buf, offset, len);
+    newKv.setSequenceId(cell.getSequenceId());
+    List<Cell> testCells = Arrays.asList(cell, cell, newKv);
+    for (Cell c : testCells) {
+      long sizeBeforeRollback = store.heapSize();
+      store.add(cell);
+      store.rollback(cell);
+      long sizeAeforeRollback = store.heapSize();
+      assertEquals(sizeBeforeRollback, sizeAeforeRollback);
+    }
+  }
+
+  @Test
   public void testLowestModificationTime() throws Exception {
     Configuration conf = HBaseConfiguration.create();
     FileSystem fs = FileSystem.get(conf);