From df2daf9e1e4bb9767b8184dc2f5da862fc46d200 Mon Sep 17 00:00:00 2001 From: haxiaolin Date: Tue, 16 Mar 2021 05:47:27 +0800 Subject: [PATCH] HBASE-25621 Balancer should check region plan source to avoid misplace region groups (#3002) Signed-off-by: stack --- .../java/org/apache/hadoop/hbase/master/HMaster.java | 2 +- .../hbase/master/assignment/AssignmentManager.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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 67dfcb6df96..9f158919cf1 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 @@ -1737,7 +1737,7 @@ public class HMaster extends HRegionServer implements MasterServices { LOG.info("balance " + plan); //TODO: bulk assign try { - this.assignmentManager.moveAsync(plan); + this.assignmentManager.balance(plan); } catch (HBaseIOException hioe) { //should ignore failed plans here, avoiding the whole balance plans be aborted //later calls of balance() can fetch up the failed and skipped plans 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 9603025bec4..107330d90b4 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 @@ -725,6 +725,17 @@ public class AssignmentManager { return ProcedureSyncWait.submitProcedure(master.getMasterProcedureExecutor(), proc); } + public Future balance(RegionPlan regionPlan) throws HBaseIOException { + ServerName current = + this.getRegionStates().getRegionAssignments().get(regionPlan.getRegionInfo()); + if (!current.equals(regionPlan.getSource())) { + LOG.debug("Skip region plan {}, source server not match, current region location is {}", + regionPlan, current); + return null; + } + return moveAsync(regionPlan); + } + // ============================================================================================ // RegionTransition procedures helpers // ============================================================================================