[ https://issues.apache.org/jira/browse/HBASE-6760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13453321#comment-13453321 ]
Aditya Kishore commented on HBASE-6760: --------------------------------------- The balancer truly runs only if the re-balancing plan is calculated as not null AND not empty. i.e. within the condition {code} if (plans != null && !plans.isEmpty()) { //run balancer } {code} Further the contract of HMaster.balance() is to return true iff the balancer actually runs and re-balances the region assignments. So the name blancerRan, which is also stores the return value of the function, seems appropriate. Further, IMO, "this.cpHost.postBalance();" should only be called if the balancer has run. Or at the least pass this information (true/false or number of regions balanced in this run) to the CP but that will require interface change in MasterCoprocessorHost. > HMaster.balance() returns 'true' even if rebalancing plan is empty and the > balancer does not run > ------------------------------------------------------------------------------------------------ > > Key: HBASE-6760 > URL: https://issues.apache.org/jira/browse/HBASE-6760 > Project: HBase > Issue Type: Bug > Components: master > Reporter: Aditya Kishore > Assignee: Aditya Kishore > Priority: Minor > > The issue seems to exists due to oversight during the rewrite. In line 1289, > the variable 'plans' is created as a 'new ArrayList<RegionPlan>()' and then > in line 1298, balancerRan is calculated as (plans != null) which for obvious > reason, will always return true. > {code:title=HMaster.java (trunk:1383496)} > .... > 1289 List<RegionPlan> plans = new ArrayList<RegionPlan>(); > 1290 //Give the balancer the current cluster state. > 1291 this.balancer.setClusterStatus(getClusterStatus()); > 1292 for (Map<ServerName, List<HRegionInfo>> assignments : > assignmentsByTable.values()) { > 1293 List<RegionPlan> partialPlans = > this.balancer.balanceCluster(assignments); > 1294 if (partialPlans != null) plans.addAll(partialPlans); > 1295 } > 1296 int rpCount = 0; // number of RegionPlans balanced so far > 1297 long totalRegPlanExecTime = 0; > 1298 balancerRan = plans != null; > 1299 if (plans != null && !plans.isEmpty()) { > .... > {code} > A simple fix is to initialize 'balancerRan' to 'false', remove "balancerRan = > plans != null" and add "balancerRan = true" after "if (plans != null && > !plans.isEmpty()) {". > However, a question remains that should we call "this.cpHost.postBalance();" > if the balancer did not run at this point? > I'll attach the patch shortly if I get a confirmation on this. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira