autumnust commented on a change in pull request #3059: URL: https://github.com/apache/incubator-gobblin/pull/3059#discussion_r454033430
########## File path: gobblin-yarn/src/main/java/org/apache/gobblin/yarn/YarnService.java ########## @@ -766,13 +767,21 @@ public void onContainersAllocated(List<Container> containers) { //Iterate over the (thread-safe) set of unused instances to find the first instance that is not currently live. //Once we find a candidate instance, it is removed from the set. String instanceName = null; - Iterator<String> iterator = unusedHelixInstanceNames.iterator(); - while (iterator.hasNext()) { - instanceName = iterator.next(); - if (!HelixUtils.isInstanceLive(helixManager, instanceName)) { - iterator.remove(); - LOGGER.info("Found an unused instance {}", instanceName); - break; + + //Ensure that updates to unusedHelixInstanceNames are visible to other threads that might concurrently + //invoke the callback on container allocation. + synchronized (lock) { Review comment: Why using explicit lock instead of intrinsic lock here? ---------------------------------------------------------------- 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: us...@infra.apache.org