Skip to content
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

PHOENIX-6104 SplitSystemCatalogIT tests very unstable with Hbase 2.3 #1038

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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 @@ -405,35 +405,6 @@ private void snapshotCreateSync(TableName hbaseTableName,
}
}

private void splitTableSync(Admin admin, TableName hbaseTableName,
byte[] splitPoint, int expectedRegions) throws IOException,
InterruptedException {
admin.split(hbaseTableName, splitPoint);
AssignmentManager assignmentManager =
getUtility().getHBaseCluster().getMaster().getAssignmentManager();
// wait for split daughter regions coming online for ~20s
for (int i = 0; i < 20; i++) {
Thread.sleep(1000);
List<HRegion> regions = getUtility().getHBaseCluster()
.getRegions(hbaseTableName);
if (regions.size() >= expectedRegions) {
boolean allRegionsOnline = true;
for (HRegion region : regions) {
if (!assignmentManager.getRegionStates()
.isRegionOnline(region.getRegionInfo())) {
allRegionsOnline = false;
break;
}
}
if (allRegionsOnline) {
break;
}
}
LOGGER.info("Sleeping for 1000 ms while waiting for {} to split and all regions to come online",
hbaseTableName.getNameAsString());
}
}

private void deleteSnapshotIfExists(String snapshotName) throws Exception {
try (Connection conn = DriverManager.getConnection(getUrl());
Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
Expand Down
38 changes: 28 additions & 10 deletions phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
import org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.assignment.AssignmentManager;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.RSRpcServices;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -1824,20 +1825,35 @@ private static void verifySequence(String tenantID, String sequenceName, String
}
phxConn.close();
}


/**
* Synchronously split table at the given split point
*/
protected static void splitRegion(TableName fullTableName, byte[] splitPoint) throws SQLException, IOException, InterruptedException {
Admin admin =
driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin();
admin.split(fullTableName, splitPoint);
// make sure the split finishes (there's no synchronous splitting before HBase 2.x)
admin.disableTable(fullTableName);
admin.enableTable(fullTableName);
protected static void splitTableSync(Admin admin, TableName hbaseTableName, byte[] splitPoint,
int expectedRegions) throws IOException, InterruptedException {
admin.split(hbaseTableName, splitPoint);
for (int i = 0; i < 30; i++) {
List<HRegion> regions = getUtility().getHBaseCluster().getRegions(hbaseTableName);
if (regions.size() >= expectedRegions) {
boolean splitSuccessful = true;
for (HRegion region : regions) {
if (!region.isSplittable()) {
splitSuccessful = false;
}
}
if(splitSuccessful) {
return;
}
}
LOGGER.info(
"Sleeping for 1000 ms while waiting for {} to split and all regions to come online",
hbaseTableName.getNameAsString());
Thread.sleep(1000);
}
throw new IOException("Split did not succeed for table: " + hbaseTableName.getNameAsString()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is better since we are anyways going to return from if(splitSuccessful)

+ " , expected regions after split: " + expectedRegions);
}

/**
* Returns true if the region contains atleast one of the metadata rows we are interested in
*/
Expand Down Expand Up @@ -1866,8 +1882,10 @@ protected static void splitTable(TableName fullTableName, List<byte[]> splitPoin
AssignmentManager am = master.getAssignmentManager();
// No need to split on the first splitPoint since the end key of region boundaries are exclusive
for (int i=1; i<splitPoints.size(); ++i) {
splitRegion(fullTableName, splitPoints.get(i));
splitTableSync(admin, fullTableName, splitPoints.get(i), i + 1);
}
List<RegionInfo> regionInfoList = admin.getRegions(fullTableName);
assertEquals(splitPoints.size(), regionInfoList.size());
HashMap<ServerName, List<HRegionInfo>> serverToRegionsList = Maps.newHashMapWithExpectedSize(NUM_SLAVES_BASE);
Deque<ServerName> availableRegionServers = new ArrayDeque<ServerName>(NUM_SLAVES_BASE);
for (int i=0; i<NUM_SLAVES_BASE; ++i) {
Expand Down