You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2010/10/06 23:27:16 UTC
svn commit: r1005261 - in /hbase/trunk: CHANGES.txt
src/main/java/org/apache/hadoop/hbase/KeyValue.java
src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java
Author: rawson
Date: Wed Oct 6 21:27:16 2010
New Revision: 1005261
URL: http://svn.apache.org/viewvc?rev=1005261&view=rev
Log:
HBASE-3008 Memstore.updateColumnValue passes wrong flag to heapSizeChange (Causes memstore size to go negative)
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java
hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java
Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1005261&r1=1005260&r2=1005261&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Wed Oct 6 21:27:16 2010
@@ -568,6 +568,8 @@ Release 0.21.0 - Unreleased
HBASE-3059 TestReadWriteConsistencyControl occasionally hangs (Hairong
via Ryan)
HBASE-2906 [rest/stargate] URI decoding in RowResource
+ HBASE-3008 Memstore.updateColumnValue passes wrong flag to heapSizeChange
+ (Causes memstore size to go negative)
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable
Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java?rev=1005261&r1=1005260&r2=1005261&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java Wed Oct 6 21:27:16 2010
@@ -1933,7 +1933,6 @@ public class KeyValue implements Writabl
ClassSize.align(ClassSize.ARRAY) + ClassSize.align(length) +
(3 * Bytes.SIZEOF_INT) +
ClassSize.align(ClassSize.ARRAY) +
- ClassSize.align((rowCache == null ? 0 : rowCache.length)) +
(2 * Bytes.SIZEOF_LONG));
}
Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1005261&r1=1005260&r2=1005261&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java Wed Oct 6 21:27:16 2010
@@ -1958,6 +1958,22 @@ public class TestHRegion extends HBaseTe
assertICV(row, fam1, qual1, value+amount);
}
+ public void testIncrementColumnValue_heapSize() throws IOException {
+ EnvironmentEdgeManagerTestHelper.injectEdge(new IncrementingEnvironmentEdge());
+
+ initHRegion(tableName, getName(), fam1);
+
+ long byAmount = 1L;
+ long size;
+
+ for( int i = 0; i < 1000 ; i++) {
+ region.incrementColumnValue(row, fam1, qual1, byAmount, true);
+
+ size = region.memstoreSize.get();
+ assertTrue("memstore size: " + size, size >= 0);
+ }
+ }
+
public void testIncrementColumnValue_UpdatingInPlace_Negative()
throws IOException {
initHRegion(tableName, getName(), fam1);
Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java?rev=1005261&r1=1005260&r2=1005261&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java Wed Oct 6 21:27:16 2010
@@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.regionser
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;
+import org.apache.hadoop.hbase.util.IncrementingEnvironmentEdge;
import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
import org.apache.hadoop.security.UnixUserGroupInformation;
@@ -69,6 +70,7 @@ public class TestStore extends TestCase
byte [] family = Bytes.toBytes("family");
byte [] row = Bytes.toBytes("row");
+ byte [] row2 = Bytes.toBytes("row2");
byte [] qf1 = Bytes.toBytes("qf1");
byte [] qf2 = Bytes.toBytes("qf2");
byte [] qf3 = Bytes.toBytes("qf3");
@@ -332,6 +334,62 @@ public class TestStore extends TestCase
assertEquals(oldValue, Bytes.toLong(results.get(1).getValue()));
}
+ public void testICV_negMemstoreSize() throws IOException {
+ init(this.getName());
+
+ long time = 100;
+ ManualEnvironmentEdge ee = new ManualEnvironmentEdge();
+ ee.setValue(time);
+ EnvironmentEdgeManagerTestHelper.injectEdge(ee);
+ long newValue = 3L;
+ long size = 0;
+
+
+ size += this.store.add(new KeyValue(Bytes.toBytes("200909091000"), family, qf1,
+ System.currentTimeMillis(),
+ Bytes.toBytes(newValue)));
+ size += this.store.add(new KeyValue(Bytes.toBytes("200909091200"), family, qf1,
+ System.currentTimeMillis(),
+ Bytes.toBytes(newValue)));
+ size += this.store.add(new KeyValue(Bytes.toBytes("200909091300"), family, qf1,
+ System.currentTimeMillis(),
+ Bytes.toBytes(newValue)));
+ size += this.store.add(new KeyValue(Bytes.toBytes("200909091400"), family, qf1,
+ System.currentTimeMillis(),
+ Bytes.toBytes(newValue)));
+ size += this.store.add(new KeyValue(Bytes.toBytes("200909091500"), family, qf1,
+ System.currentTimeMillis(),
+ Bytes.toBytes(newValue)));
+
+
+ for ( int i = 0 ; i < 10000 ; ++i) {
+ newValue++;
+
+ long ret = this.store.updateColumnValue(row, family, qf1, newValue);
+ long ret2 = this.store.updateColumnValue(row2, family, qf1, newValue);
+
+ if (ret != 0) System.out.println("ret: " + ret);
+ if (ret2 != 0) System.out.println("ret2: " + ret2);
+
+ assertTrue("ret: " + ret, ret >= 0);
+ size += ret;
+ assertTrue("ret2: " + ret2, ret2 >= 0);
+ size += ret2;
+
+
+ if (i % 1000 == 0)
+ ee.setValue(++time);
+ }
+
+ long computedSize=0;
+ for (KeyValue kv : this.store.memstore.kvset) {
+ long kvsize = this.store.memstore.heapSizeChange(kv, true);
+ //System.out.println(kv + " size= " + kvsize + " kvsize= " + kv.heapSize());
+ computedSize += kvsize;
+ }
+ assertEquals(computedSize, size);
+ }
+
public void testIncrementColumnValue_SnapshotFlushCombo() throws Exception {
ManualEnvironmentEdge mee = new ManualEnvironmentEdge();
EnvironmentEdgeManagerTestHelper.injectEdge(mee);