From cfe569cf6b544213188a276408e7197d697e6edf Mon Sep 17 00:00:00 2001 From: stack Date: Fri, 24 Jan 2020 10:06:18 -0800 Subject: [PATCH] HBASE-23733 [Flakey Tests] TestSplitTransactionOnCluster --- .../TestSplitTransactionOnCluster.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java index 2fb822ec8f9..72b68356829 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -84,6 +84,7 @@ import org.apache.hadoop.hbase.master.assignment.RegionStateNode; import org.apache.hadoop.hbase.master.assignment.RegionStates; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.regionserver.compactions.CompactionContext; +import org.apache.hadoop.hbase.regionserver.compactions.CompactionProgress; import org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; @@ -360,10 +361,8 @@ public class TestSplitTransactionOnCluster { final TableName tableName = TableName.valueOf(name.getMethodName()); // Create table then get the single region for our new table. - Table t = createTableAndWait(tableName, HConstants.CATALOG_FAMILY); - List regions = cluster.getRegions(tableName); - RegionInfo hri = getAndCheckSingleTableRegion(regions); - + Table t = createTableAndWait(tableName, HConstants.CATALOG_FAMILY); List regions = + cluster.getRegions(tableName); RegionInfo hri = getAndCheckSingleTableRegion(regions); int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri); // Turn off balancer so it doesn't cut in and mess up our placements. @@ -380,20 +379,31 @@ public class TestSplitTransactionOnCluster { admin.splitRegionAsync(hri.getRegionName()).get(2, TimeUnit.MINUTES); // Get daughters List daughters = checkAndGetDaughters(tableName); - HRegion daughterRegion = daughters.get(0); // Now split one of the daughters. + HRegion daughterRegion = daughters.get(0); RegionInfo daughter = daughterRegion.getRegionInfo(); LOG.info("Daughter we are going to split: " + daughter); - // Compact first to ensure we have cleaned up references -- else the split - // will fail. + // Compact first to ensure we have cleaned up references -- else the split will fail. + // May be a compaction going already so compact will return immediately; if so, wait until + // compaction completes. daughterRegion.compact(true); - daughterRegion.getStores().get(0).closeAndArchiveCompactedFiles(); + HStore store = daughterRegion.getStores().get(0); + CompactionProgress progress = store.getCompactionProgress(); + if (progress != null) { + while (progress.getProgressPct() < 1) { + LOG.info("Waiting {}", progress); + Threads.sleep(1000); + } + } + store.closeAndArchiveCompactedFiles(); for (int i = 0; i < 100; i++) { if (!daughterRegion.hasReferences()) { + LOG.info("Break -- no references in {}", daughterRegion); break; } Threads.sleep(100); } + LOG.info("Finished {} references={}", daughterRegion, daughterRegion.hasReferences()); assertFalse("Waiting for reference to be compacted", daughterRegion.hasReferences()); LOG.info("Daughter hri before split (has been compacted): " + daughter); admin.splitRegionAsync(daughter.getRegionName()).get(2, TimeUnit.MINUTES);