HBASE-21425 2.1.1 fails to start over 1.x data; namespace not assigned

This commit is contained in:
Michael Stack 2018-11-01 12:58:15 -07:00
parent 62fe365934
commit d08990c962
3 changed files with 19 additions and 11 deletions

View File

@ -1081,6 +1081,12 @@ public class HMaster extends HRegionServer implements MasterServices {
this.assignmentManager.joinCluster();
// The below depends on hbase:meta being online.
this.tableStateManager.start();
// Below has to happen after tablestatemanager has started in the case where this hbase-2.x
// is being started over an hbase-1.x dataset. tablestatemanager runs a migration as part
// of its 'start' moving table state from zookeeper to hbase:meta. This migration needs to
// complete before we do this next step processing offline regions else it fails reading
// table states messing up master launch (namespace table, etc., are not assigned).
this.assignmentManager.processOfflineRegions();
// Initialize after meta is up as below scans meta
if (favoredNodesManager != null && !maintenanceMode) {
SnapshotOfRegionAssignmentFromMeta snapshotOfRegionAssignment =

View File

@ -273,7 +273,7 @@ public class TableStateManager {
throws IOException {
Map<String, TableDescriptor> allDescriptors = tableDescriptors.getAll();
Map<String, TableState> states = new HashMap<>();
// NOTE: Ful hbase:meta table scan!
// NOTE: Full hbase:meta table scan!
MetaTableAccessor.fullScanTables(connection, new MetaTableAccessor.Visitor() {
@Override
public boolean visit(Result r) throws IOException {

View File

@ -1264,8 +1264,6 @@ public class AssignmentManager implements ServerListener {
}
LOG.info("Number of RegionServers={}", master.getServerManager().countOfRegionServers());
processOfflineRegions();
// Start the RIT chore
master.getMasterProcedureExecutor().addChore(this.ritChore);
@ -1273,14 +1271,18 @@ public class AssignmentManager implements ServerListener {
LOG.info("Joined the cluster in {}", StringUtils.humanTimeDiff(costMs));
}
// Create assign procedure for offline regions.
// Just follow the old processofflineServersWithOnlineRegions method. Since now we do not need to
// deal with dead server any more, we only deal with the regions in OFFLINE state in this method.
// And this is a bit strange, that for new regions, we will add it in CLOSED state instead of
// OFFLINE state, and usually there will be a procedure to track them. The
// processofflineServersWithOnlineRegions is a legacy from long ago, as things are going really
// different now, maybe we do not need this method any more. Need to revisit later.
private void processOfflineRegions() {
/**
* Create assign procedure for offline regions.
* Just follow the old processofflineServersWithOnlineRegions method. Since now we do not need to
* deal with dead server any more, we only deal with the regions in OFFLINE state in this method.
* And this is a bit strange, that for new regions, we will add it in CLOSED state instead of
* OFFLINE state, and usually there will be a procedure to track them. The
* processofflineServersWithOnlineRegions is a legacy from long ago, as things are going really
* different now, maybe we do not need this method any more. Need to revisit later.
*/
// Public so can be run by the Master as part of the startup. Needs hbase:meta to be online.
// Needs to be done after the table state manager has been started.
public void processOfflineRegions() {
List<RegionInfo> offlineRegions = regionStates.getRegionStates().stream()
.filter(RegionState::isOffline).filter(s -> isTableEnabled(s.getRegion().getTable()))
.map(RegionState::getRegion).collect(Collectors.toList());