HBASE-25513 When the table is turned on normalize, the first region may not be merged even the size is 0 (#2887)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
This commit is contained in:
parent
6c3861f65d
commit
bc4f5c2709
|
@ -364,6 +364,10 @@ class SimpleRegionNormalizer implements RegionNormalizer, ConfigurationObserver
|
|||
if (rangeMembers.isEmpty() // when there are no range members, seed the range with whatever
|
||||
// we have. this way we're prepared in case the next region is
|
||||
// 0-size.
|
||||
|| (rangeMembers.size() == 1 && sumRangeMembersSizeMb == 0) // when there is only one
|
||||
// region and the size is 0,
|
||||
// seed the range with
|
||||
// whatever we have.
|
||||
|| regionSizeMb == 0 // always add an empty region to the current range.
|
||||
|| (regionSizeMb + sumRangeMembersSizeMb <= avgRegionSizeMb)) { // add the current region
|
||||
// to the range when
|
||||
|
|
|
@ -448,6 +448,38 @@ public class TestSimpleRegionNormalizer {
|
|||
.build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergeEmptyRegions2() {
|
||||
conf.setBoolean(SPLIT_ENABLED_KEY, false);
|
||||
conf.setInt(MERGE_MIN_REGION_SIZE_MB_KEY, 0);
|
||||
final TableName tableName = name.getTableName();
|
||||
final List<RegionInfo> regionInfos = createRegionInfos(tableName, 8);
|
||||
final Map<byte[], Integer> regionSizes =
|
||||
createRegionSizesMap(regionInfos, 0, 10, 1, 0, 9, 0, 10, 0);
|
||||
setupMocksForNormalizer(regionSizes, regionInfos);
|
||||
|
||||
assertFalse(normalizer.isSplitEnabled());
|
||||
assertEquals(0, normalizer.getMergeMinRegionSizeMb());
|
||||
List<NormalizationPlan> plans = normalizer.computePlansForTable(tableName);
|
||||
assertThat(plans, contains(
|
||||
new MergeNormalizationPlan.Builder()
|
||||
.addTarget(regionInfos.get(0), 0)
|
||||
.addTarget(regionInfos.get(1), 10)
|
||||
.build(),
|
||||
new MergeNormalizationPlan.Builder()
|
||||
.addTarget(regionInfos.get(2), 1)
|
||||
.addTarget(regionInfos.get(3), 0)
|
||||
.build(),
|
||||
new MergeNormalizationPlan.Builder()
|
||||
.addTarget(regionInfos.get(4), 9)
|
||||
.addTarget(regionInfos.get(5), 0)
|
||||
.build(),
|
||||
new MergeNormalizationPlan.Builder()
|
||||
.addTarget(regionInfos.get(6), 10)
|
||||
.addTarget(regionInfos.get(7), 0)
|
||||
.build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitAndMultiMerge() {
|
||||
conf.setInt(MERGE_MIN_REGION_SIZE_MB_KEY, 0);
|
||||
|
|
Loading…
Reference in New Issue