Skip to content

HBASE-22198 Fix flakey TestAsyncTableGetMultiThreaded #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.apache.hadoop.hbase.master.LoadBalancer.TABLES_ON_MASTER;
import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -34,7 +35,6 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
Expand All @@ -55,6 +55,8 @@
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Will split the table, and move region randomly when testing.
Expand All @@ -64,7 +66,9 @@ public class TestAsyncTableGetMultiThreaded {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestAsyncTableGetMultiThreaded.class);
HBaseClassTestRule.forClass(TestAsyncTableGetMultiThreaded.class);

private static final Logger LOG = LoggerFactory.getLogger(TestAsyncTableGetMultiThreaded.class);

private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();

Expand Down Expand Up @@ -155,12 +159,23 @@ public String explainFailure() throws Exception {

for (HRegion region : TEST_UTIL.getHBaseCluster().getRegions(TABLE_NAME)) {
region.compact(true);

//Waiting for compaction to complete and references are cleaned up
}
for (HRegion region : TEST_UTIL.getHBaseCluster().getRegions(TABLE_NAME)) {
// Waiting for compaction to complete and references are cleaned up
RetryCounter retrier = new RetryCounter(30, 1, TimeUnit.SECONDS);
while (CompactionState.NONE != admin
.getCompactionStateForRegion(region.getRegionInfo().getRegionName())
&& retrier.shouldRetry()) {
for (;;) {
try {
if (admin.getCompactionStateForRegion(
region.getRegionInfo().getRegionName()) == CompactionState.NONE) {
break;
}
} catch (IOException e) {
LOG.warn("Failed to query");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the difference is here ? even if the region is not online, we'll retry unti exhaust or fail ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UT aims to test whether we can deal with region moving/splitting, so it is possible that the region is not online at some point, but the admin method will not fail immediately without retrying, which is not like what we do in normal get/put operation, so here we need to catch the exception and use an external RetryCounter to retry. Otherwise it will cause the test to fail.

}
if (!retrier.shouldRetry()) {
throw new IOException("Can not finish compaction in time after attempt " +
retrier.getAttemptTimes() + " times");
}
retrier.sleepUntilNextRetry();
}
region.getStores().get(0).closeAndArchiveCompactedFiles();
Expand Down