You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/03/12 18:33:42 UTC

[GitHub] [helix] NealSun96 opened a new pull request #889: Remove possible score-tie between two AssignableNodes

NealSun96 opened a new pull request #889: Remove possible score-tie between two AssignableNodes
URL: https://github.com/apache/helix/pull/889
 
 
   ### Issues
   
   - [x] My PR addresses the following Helix issues and references them in the PR description:
   
   Fixes #772 
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   
   When a single resource is scaled up or down, we noticed dramatic divergence between Baseline and Best possible assignments. We concluded initially that it could be caused by some unexpected randomness in the algorithm, and we found out this potential score-tie during node evaluation. This PR fixes a potential situation where two AssignableNodes will receive the same score; the fix makes the algorithm more deterministic. 
   
   After further experiments and discussions, we realized that the divergence might be caused by Baseline recalculation after IdealState changes. See #772. This topic will be explored further in another issue. 
   
   ### Tests
   
   - [x] The following tests are written for this issue:
   
   TestConstraintBasedAlgorithm.testCalculateScoreDeterminism
   
   - [ ] The following is the result of the "mvn test" command on the appropriate module:
   
   (Copy & paste the result of "mvn test")
   
   ### Commits
   
   - [x] My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - [x] My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #889: Remove possible score-tie between two AssignableNodes

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #889: Remove possible score-tie between two AssignableNodes
URL: https://github.com/apache/helix/pull/889#discussion_r392390285
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithm.java
 ##########
 @@ -122,9 +121,12 @@ public OptimalAssignment calculate(ClusterModel clusterModel)
           if (scoreCompareResult == 0) {
             // If the evaluation scores of 2 nodes are the same, the algorithm assigns the replica
             // to the idle node first.
-            int idleScore1 = busyInstances.contains(nodeEntry1.getKey().getInstanceName()) ? 0 : 1;
-            int idleScore2 = busyInstances.contains(nodeEntry2.getKey().getInstanceName()) ? 0 : 1;
-            return idleScore1 - idleScore2;
+            String instanceName1 = nodeEntry1.getKey().getInstanceName();
+            String instanceName2 = nodeEntry2.getKey().getInstanceName();
+            int idleScore1 = busyInstances.contains(instanceName1) ? 0 : 1;
+            int idleScore2 = busyInstances.contains(instanceName2) ? 0 : 1;
+            return idleScore1 != idleScore2 ? idleScore1 - idleScore2
 
 Review comment:
   nit, adding parenthesis to the calculation so it is cleaner and safer.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] NealSun96 commented on issue #889: Remove possible score-tie between two AssignableNodes

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on issue #889: Remove possible score-tie between two AssignableNodes
URL: https://github.com/apache/helix/pull/889#issuecomment-598956108
 
 
   This PR is ready to be merged, approved by @jiajunwang 
   Final commit message:
   ## Remove possible score-tie between two AssignableNodes ##
   This PR fixes a potential situation where two AssignableNodes will receive the same score; the fix makes the algorithm more deterministic.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang merged pull request #889: Remove possible score-tie between two AssignableNodes

Posted by GitBox <gi...@apache.org>.
jiajunwang merged pull request #889: Remove possible score-tie between two AssignableNodes
URL: https://github.com/apache/helix/pull/889
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org