vli02 commented on a change in pull request #3402:
URL: https://github.com/apache/hbase/pull/3402#discussion_r658889227
##########
File path:
hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
##########
@@ -882,6 +882,80 @@ public void testDupeStartKey() throws Exception {
assertNoErrors(hbck2);
assertEquals(0, hbck2.getOverlapGroups(table).size());
assertEquals(ROWKEYS.length, countRows());
+
+ MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
+ long totalRegions = cluster.countServedRegions();
+
+ // stop a region servers and run fsck again
+ cluster.stopRegionServer(server);
+ cluster.waitForRegionServerToStop(server, 60);
+
+ // wait for all regions to come online.
+ while (cluster.countServedRegions() < totalRegions) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {}
+ }
+
+ // check again after stopping a region server.
+ HBaseFsck hbck3 = doFsck(conf,false);
+ assertNoErrors(hbck3);
+ } finally {
+ cleanupTable(table);
+ }
+ }
+
+ /**
+ * This create and fixes a bad table with regions that have overlap regions.
+ */
+ @Test(timeout=180000)
+ public void testOverlapRegions() throws Exception {
+ MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
+ TableName table =
+ TableName.valueOf("tableOverlapRegions");
+ HRegionInfo hri;
+ ServerName server;
+ try {
+ setupTable(table);
+ assertNoErrors(doFsck(conf, false));
+ assertEquals(ROWKEYS.length, countRows());
+
+ // Now let's mess it up, by adding a region which overlaps with others
+ hri = createRegion(tbl.getTableDescriptor(), Bytes.toBytes("A2"),
Bytes.toBytes("B2"));
+ TEST_UTIL.assignRegion(hri);
+ server = regionStates.getRegionServerOfRegion(hri);
+ TEST_UTIL.assertRegionOnServer(hri, server, REGION_ONLINE_TIMEOUT);
+
+ HBaseFsck hbck = doFsck(conf, false);
+ assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.OVERLAP_IN_REGION_CHAIN,
+ ERROR_CODE.OVERLAP_IN_REGION_CHAIN });
+ assertEquals(3, hbck.getOverlapGroups(table).size());
+ assertEquals(ROWKEYS.length, countRows());
+
+ // fix the overlap regions.
+ doFsck(conf, true);
+
+ // check that the overlap regions are gone and no data loss
+ HBaseFsck hbck2 = doFsck(conf,false);
+ assertNoErrors(hbck2);
+ assertEquals(0, hbck2.getOverlapGroups(table).size());
+ assertEquals(ROWKEYS.length, countRows());
+
+ long totalRegions = cluster.countServedRegions();
+
+ // stop a region servers and run fsck again
+ cluster.stopRegionServer(server);
+ cluster.waitForRegionServerToStop(server, 60);
+
+ // wait for all regions to come online.
+ while (cluster.countServedRegions() < totalRegions) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {}
Review comment:
Sounds good. Fixed. Re-run the fscb test without catching this
exception, it passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]