From d08990c962a3865a614f23e20ffa1bd3f538fdee Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 1 Nov 2018 12:58:15 -0700 Subject: [PATCH] HBASE-21425 2.1.1 fails to start over 1.x data; namespace not assigned --- .../apache/hadoop/hbase/master/HMaster.java | 6 +++++ .../hbase/master/TableStateManager.java | 2 +- .../master/assignment/AssignmentManager.java | 22 ++++++++++--------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 1efffbd35d1..adf1dcdae07 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -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 = diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableStateManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableStateManager.java index 6e3461873ea..580e726b873 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableStateManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableStateManager.java @@ -273,7 +273,7 @@ public class TableStateManager { throws IOException { Map allDescriptors = tableDescriptors.getAll(); Map 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 { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java index e9309e15032..08536b7cbd5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java @@ -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 offlineRegions = regionStates.getRegionStates().stream() .filter(RegionState::isOffline).filter(s -> isTableEnabled(s.getRegion().getTable())) .map(RegionState::getRegion).collect(Collectors.toList());