From e08ef99e3042767eaf2d11adae783674acfdddeb Mon Sep 17 00:00:00 2001 From: tedyu Date: Thu, 16 Apr 2015 11:36:25 -0700 Subject: [PATCH] HBASE-13473 deleted cells come back alive after the stripe compaction (jeongmin kim) --- .../compactions/StripeCompactionPolicy.java | 2 +- .../compactions/TestStripeCompactionPolicy.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/StripeCompactionPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/StripeCompactionPolicy.java index 5231662504d..0d49f095427 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/StripeCompactionPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/StripeCompactionPolicy.java @@ -248,7 +248,7 @@ public class StripeCompactionPolicy extends CompactionPolicy { req = new SplitStripeCompactionRequest( filesToCompact, si.getStartRow(bqIndex), si.getEndRow(bqIndex), targetCount, targetKvs); } - if (canDropDeletesWithoutL0 || includeL0) { + if (hasAllFiles && (canDropDeletesWithoutL0 || includeL0)) { req.setMajorRange(si.getStartRow(bqIndex), si.getEndRow(bqIndex)); } req.getRequest().setOffPeak(isOffpeak); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java index 81f811528ad..9350ce458d2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java @@ -40,6 +40,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Iterator; import java.util.List; import org.apache.hadoop.conf.Configuration; @@ -424,6 +425,16 @@ public class TestStripeCompactionPolicy { si = createStripesWithSizes(6, 2, new Long[][] { new Long[] { 10L, 1L, 1L, 1L, 1L }, new Long[] { 12L } }); verifyCompaction(policy, si, si.getLevel0Files(), null, null, si.getStripeBoundaries()); + // even if L0 has no file + // if all files of stripe aren't selected, delete must not be dropped. + stripes = new Long[][] { new Long[] { 100L, 3L, 2L, 2L, 2L }, new Long[] { 6L } }; + si = createStripesWithSizes(0, 0, stripes); + List compact_file = new ArrayList(); + Iterator iter = si.getStripes().get(0).listIterator(1); + while (iter.hasNext()) { + compact_file.add(iter.next()); + } + verifyCompaction(policy, si, compact_file, false, 1, null, si.getStartRow(0), si.getEndRow(0), true); } /********* HELPER METHODS ************/