Skip to content

Commit

Permalink
HBASE-23771 [Flakey Tests] Test TestSplitTransactionOnCluster Again
Browse files Browse the repository at this point in the history
  • Loading branch information
saintstack committed Jan 30, 2020
1 parent 860b93d commit 76247aa
Showing 1 changed file with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,29 +383,8 @@ public void testShutdownFixupWhenDaughterHasSplit() throws Exception {
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);
Expand Down Expand Up @@ -438,6 +417,26 @@ public void testShutdownFixupWhenDaughterHasSplit() throws Exception {
}
}

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());
Expand Down Expand Up @@ -535,8 +534,7 @@ public void testMasterRestartAtRegionSplitPendingCatalogJanitor()
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
Expand Down Expand Up @@ -819,8 +817,6 @@ private HMaster abortAndWaitForMaster() throws IOException, InterruptedException
/**
* 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
Expand Down

0 comments on commit 76247aa

Please sign in to comment.