diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java index 9469096..30a28cc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java @@ -497,6 +497,83 @@ public class TestKeepDeletes { } /** + * Test delete marker removal from store files. + */ + @Test + public void testWithOldRow() throws Exception { + HTableDescriptor htd = hbu.createTableDescriptor(name.getMethodName(), 0, 1, + HConstants.FOREVER, true); + HRegion region = hbu.createLocalHRegion(htd, null, null); + + long ts = EnvironmentEdgeManager.currentTime(); + + Put p = new Put(T1, ts); + p.add(c0, c0, T1); + region.put(p); + + // a put another (older) row in the same store + p = new Put(T2, ts-10); + p.add(c0, c0, T1); + region.put(p); + + // all the following deletes affect the put + Delete d = new Delete(T1, ts); + d.deleteColumns(c0, c0, ts); + region.delete(d); + + d = new Delete(T1, ts); + d.deleteFamily(c0, ts); + region.delete(d); + + d = new Delete(T1, ts); + d.deleteColumn(c0, c0, ts+1); + region.delete(d); + + d = new Delete(T1, ts); + d.deleteColumn(c0, c0, ts+2); + region.delete(d); + + // 1 family marker, 1 column marker, 2 version markers + assertEquals(4, countDeleteMarkers(region)); + + region.flushcache(); + assertEquals(4, countDeleteMarkers(region)); + region.compactStores(false); + assertEquals(4, countDeleteMarkers(region)); + + // another put will push out the earlier put... + p = new Put(T1, ts+3); + p.add(c0, c0, T1); + region.put(p); + + region.flushcache(); + // no markers are collected, since there is an affected put + region.compactStores(true); + assertEquals(4, countDeleteMarkers(region)); + + // all markers remain, since we have the older row + // and we haven't pushed the inlined markers past MAX_VERSIONS + region.compactStores(true); + assertEquals(4, countDeleteMarkers(region)); + + // another put will push out the earlier put... + p = new Put(T1, ts+4); + p.add(c0, c0, T1); + region.put(p); + + // this pushed out the column and version marker + // but the family markers remains. THIS IS A PROBLEM! + region.compactStores(true); + assertEquals(1, countDeleteMarkers(region)); + + // no amount of compactin is getting this of this one + region.compactStores(true); + assertEquals(1, countDeleteMarkers(region)); + + HRegion.closeHRegion(region); + } + + /** * Verify correct range demarcation */ @Test