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

This commit is contained in:
tedyu 2017-01-23 09:30:39 -08:00
parent 6e0f3f5bbc
commit 50ecbf1c8a
2 changed files with 26 additions and 2 deletions

View File

@ -347,8 +347,8 @@ public class DefaultMemStore implements MemStore {
// If the key is in the memstore, delete it. Update this.size. // If the key is in the memstore, delete it. Update this.size.
found = this.cellSet.get(cell); found = this.cellSet.get(cell);
if (found != null && found.getSequenceId() == cell.getSequenceId()) { if (found != null && found.getSequenceId() == cell.getSequenceId()) {
removeFromCellSet(cell); removeFromCellSet(found);
long s = heapSizeChange(cell, true); long s = heapSizeChange(found, true);
this.size.addAndGet(-s); this.size.addAndGet(-s);
} }
} }

View File

@ -90,6 +90,7 @@ import org.junit.rules.TestName;
import org.mockito.Mockito; import org.mockito.Mockito;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.Arrays;
/** /**
* Test class for the Store * Test class for the Store
@ -358,6 +359,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 @Test
public void testLowestModificationTime() throws Exception { public void testLowestModificationTime() throws Exception {
Configuration conf = HBaseConfiguration.create(); Configuration conf = HBaseConfiguration.create();