HBASE-23771 [Flakey Tests] Test TestSplitTransactionOnCluster Again

This commit is contained in:
stack 2020-01-29 22:36:13 -08:00
parent 77229c79e3
commit 1a6bdc7c50
1 changed files with 22 additions and 26 deletions

View File

@ -384,29 +384,8 @@ public class TestSplitTransactionOnCluster {
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.
// May be a compaction going already so compact will return immediately; if so, wait until
// compaction completes.
daughterRegion.compact(true);
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);
}
clearReferences(daughterRegion);
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);
// Get list of daughters
daughters = cluster.getRegions(tableName);
@ -439,6 +418,26 @@ public class TestSplitTransactionOnCluster {
}
}
private void clearReferences(HRegion region) throws IOException {
// Presumption.
assertEquals(1, region.getStores().size());
HStore store = region.getStores().get(0);
while (store.hasReferences()) {
// Wait on any current compaction to complete first.
CompactionProgress progress = store.getCompactionProgress();
if (progress != null && progress.getProgressPct() < 1.0f) {
while (progress.getProgressPct() < 1.0f) {
LOG.info("Waiting, progress={}", progress.getProgressPct());
Threads.sleep(1000);
}
} else {
// Run new compaction. Shoudn't be any others running.
region.compact(true);
}
store.closeAndArchiveCompactedFiles();
}
}
@Test
public void testSplitShouldNotThrowNPEEvenARegionHasEmptySplitFiles() throws Exception {
TableName userTableName = TableName.valueOf(name.getMethodName());
@ -536,8 +535,7 @@ public class TestSplitTransactionOnCluster {
HMaster master = abortAndWaitForMaster();
// Now call compact on the daughters and clean up any references.
for (HRegion daughter : daughters) {
daughter.compact(true);
daughter.getStores().get(0).closeAndArchiveCompactedFiles();
clearReferences(daughter);
assertFalse(daughter.hasReferences());
}
// BUT calling compact on the daughters is not enough. The CatalogJanitor looks
@ -820,8 +818,6 @@ public class TestSplitTransactionOnCluster {
/**
* Ensure single table region is not on same server as the single hbase:meta table
* region.
* @param admin
* @param hri
* @return Index of the server hosting the single table region
* @throws UnknownRegionException
* @throws MasterNotRunningException