Github user jiajunwang commented on a diff in the pull request: https://github.com/apache/helix/pull/88#discussion_r117137720 --- Diff: helix-core/src/main/java/org/apache/helix/task/JobRebalancer.java --- @@ -455,6 +454,44 @@ private ResourceAssignment computeResourceMapping(String jobResource, return ra; } + /** + * If assignment is different from previous assignment, drop the old running task if it's no + * longer assigned to the same instance, but not removing it from excludeSet because the same task + * should not be assigned to the new instance right way. + */ + private void dropRebalancedRunningTasks(Map<String, SortedSet<Integer>> newAssignment, + Map<String, SortedSet<Integer>> oldAssignment, Map<Integer, PartitionAssignment> paMap, + JobContext jobContext) { + for (String instance : oldAssignment.keySet()) { + for (Integer pId : oldAssignment.get(instance)) { + if (jobContext.getPartitionState(pId) == TaskPartitionState.RUNNING + && !newAssignment.get(instance).contains(pId)) { + paMap.put(pId, new PartitionAssignment(instance, TaskPartitionState.DROPPED.name())); + jobContext.setPartitionState(pId, TaskPartitionState.DROPPED); --- End diff -- Do we need to set DROPPED here? New status will be updated by updateJobContextAndGetTaskCurrentState() next round, right? One problem of setting DROPPED here is that if the participant cannot cancel the job in a short time, it's status will still be RUNNING. Then in the first round, the controller sets it to be DROPPED. In the second round, it will be changed back to RUNNING. Although, eventually the state will be correct, it is confusing during this period.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---