HBASE-23321 [hbck2] fixHoles of fixMeta doesn't update in-memory state
This commit is contained in:
parent
96fd75bd0e
commit
bcd2aa9a9e
|
@ -29,7 +29,6 @@ import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.MetaTableAccessor;
|
import org.apache.hadoop.hbase.MetaTableAccessor;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.client.Put;
|
|
||||||
import org.apache.hadoop.hbase.client.RegionInfo;
|
import org.apache.hadoop.hbase.client.RegionInfo;
|
||||||
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
|
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
|
||||||
import org.apache.hadoop.hbase.exceptions.MergeRegionException;
|
import org.apache.hadoop.hbase.exceptions.MergeRegionException;
|
||||||
|
@ -99,11 +98,13 @@ class MetaFixer {
|
||||||
HRegion.createRegionDir(configuration, ri, FSUtils.getRootDir(configuration));
|
HRegion.createRegionDir(configuration, ri, FSUtils.getRootDir(configuration));
|
||||||
// If an error here, then we'll have a region in the filesystem but not
|
// If an error here, then we'll have a region in the filesystem but not
|
||||||
// in hbase:meta (if the below fails). Should be able to rerun the fix.
|
// in hbase:meta (if the below fails). Should be able to rerun the fix.
|
||||||
// The second call to createRegionDir will just go through. Idempotent.
|
// Add to hbase:meta and then update in-memory state so it knows of new
|
||||||
Put put = MetaTableAccessor.makePutFromRegionInfo(ri, HConstants.LATEST_TIMESTAMP);
|
// Region; addRegionToMeta adds region and adds a state column set to CLOSED.
|
||||||
MetaTableAccessor.putsToMetaTable(this.masterServices.getConnection(),
|
MetaTableAccessor.addRegionToMeta(this.masterServices.getConnection(), ri);
|
||||||
Collections.singletonList(put));
|
this.masterServices.getAssignmentManager().getRegionStates().
|
||||||
LOG.info("Fixed hole by adding {}; region is NOT assigned (assign to online).", ri);
|
updateRegionState(ri, RegionState.State.CLOSED);
|
||||||
|
LOG.info("Fixed hole by adding {} in CLOSED state; region NOT assigned (assign to ONLINE).",
|
||||||
|
ri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.master;
|
package org.apache.hadoop.hbase.master;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -35,7 +36,6 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
|
||||||
import org.apache.hadoop.hbase.util.Threads;
|
import org.apache.hadoop.hbase.util.Threads;
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.ClassRule;
|
import org.junit.ClassRule;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
@ -75,6 +75,7 @@ public class TestMetaFixer {
|
||||||
TEST_UTIL.createMultiRegionTable(tn, HConstants.CATALOG_FAMILY);
|
TEST_UTIL.createMultiRegionTable(tn, HConstants.CATALOG_FAMILY);
|
||||||
List<RegionInfo> ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tn);
|
List<RegionInfo> ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tn);
|
||||||
MasterServices services = TEST_UTIL.getHBaseCluster().getMaster();
|
MasterServices services = TEST_UTIL.getHBaseCluster().getMaster();
|
||||||
|
int initialSize = services.getAssignmentManager().getRegionStates().getRegionStates().size();
|
||||||
services.getCatalogJanitor().scan();
|
services.getCatalogJanitor().scan();
|
||||||
CatalogJanitor.Report report = services.getCatalogJanitor().getLastReport();
|
CatalogJanitor.Report report = services.getCatalogJanitor().getLastReport();
|
||||||
assertTrue(report.isEmpty());
|
assertTrue(report.isEmpty());
|
||||||
|
@ -83,19 +84,23 @@ public class TestMetaFixer {
|
||||||
deleteRegion(services, ris.get(ris.size() -1));
|
deleteRegion(services, ris.get(ris.size() -1));
|
||||||
deleteRegion(services, ris.get(3));
|
deleteRegion(services, ris.get(3));
|
||||||
deleteRegion(services, ris.get(0));
|
deleteRegion(services, ris.get(0));
|
||||||
|
assertEquals(initialSize - 3,
|
||||||
|
services.getAssignmentManager().getRegionStates().getRegionStates().size());
|
||||||
services.getCatalogJanitor().scan();
|
services.getCatalogJanitor().scan();
|
||||||
report = services.getCatalogJanitor().getLastReport();
|
report = services.getCatalogJanitor().getLastReport();
|
||||||
Assert.assertEquals(report.toString(), 3, report.getHoles().size());
|
assertEquals(report.toString(), 3, report.getHoles().size());
|
||||||
MetaFixer fixer = new MetaFixer(services);
|
MetaFixer fixer = new MetaFixer(services);
|
||||||
fixer.fixHoles(report);
|
fixer.fixHoles(report);
|
||||||
services.getCatalogJanitor().scan();
|
services.getCatalogJanitor().scan();
|
||||||
report = services.getCatalogJanitor().getLastReport();
|
report = services.getCatalogJanitor().getLastReport();
|
||||||
assertTrue(report.toString(), report.isEmpty());
|
assertTrue(report.toString(), report.isEmpty());
|
||||||
|
assertEquals(initialSize,
|
||||||
|
services.getAssignmentManager().getRegionStates().getRegionStates().size());
|
||||||
// Disable and reenable so the added regions get reassigned.
|
// Disable and reenable so the added regions get reassigned.
|
||||||
TEST_UTIL.getAdmin().disableTable(tn);
|
TEST_UTIL.getAdmin().disableTable(tn);
|
||||||
TEST_UTIL.getAdmin().enableTable(tn);
|
TEST_UTIL.getAdmin().enableTable(tn);
|
||||||
ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tn);
|
ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tn);
|
||||||
Assert.assertEquals(originalCount, ris.size());
|
assertEquals(originalCount, ris.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,7 +126,7 @@ public class TestMetaFixer {
|
||||||
report = services.getCatalogJanitor().getLastReport();
|
report = services.getCatalogJanitor().getLastReport();
|
||||||
assertTrue(report.isEmpty());
|
assertTrue(report.isEmpty());
|
||||||
ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tn);
|
ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tn);
|
||||||
Assert.assertEquals(0, ris.size());
|
assertEquals(0, ris.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void makeOverlap(MasterServices services, RegionInfo a, RegionInfo b)
|
private static void makeOverlap(MasterServices services, RegionInfo a, RegionInfo b)
|
||||||
|
@ -154,8 +159,8 @@ public class TestMetaFixer {
|
||||||
Threads.sleep(10000);
|
Threads.sleep(10000);
|
||||||
services.getCatalogJanitor().scan();
|
services.getCatalogJanitor().scan();
|
||||||
report = services.getCatalogJanitor().getLastReport();
|
report = services.getCatalogJanitor().getLastReport();
|
||||||
Assert.assertEquals(6, report.getOverlaps().size());
|
assertEquals(6, report.getOverlaps().size());
|
||||||
Assert.assertEquals(1, MetaFixer.calculateMerges(10, report.getOverlaps()).size());
|
assertEquals(1, MetaFixer.calculateMerges(10, report.getOverlaps()).size());
|
||||||
MetaFixer fixer = new MetaFixer(services);
|
MetaFixer fixer = new MetaFixer(services);
|
||||||
fixer.fixOverlaps(report);
|
fixer.fixOverlaps(report);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
Loading…
Reference in New Issue