alirezazamani commented on a change in pull request #741: Fix ConcurrentModification exception in Workflow Garbage Collection URL: https://github.com/apache/helix/pull/741#discussion_r377986361
########## File path: helix-core/src/main/java/org/apache/helix/task/TaskUtil.java ########## @@ -1040,26 +1040,39 @@ public static void purgeExpiredJobs(String workflow, WorkflowConfig workflowConf /** * The function that loops through the all existing workflow contexts and removes IdealState and * workflow context of the workflow whose workflow config does not exist. + * Try-catch has been used to avoid concurrent modification exception while doing deep copy. Since + * Map.keySet() can produce concurrent modification exception. * @param dataProvider * @param manager */ - public static void workflowGarbageCollection(WorkflowControllerDataProvider dataProvider, + public static void workflowGarbageCollection(final WorkflowControllerDataProvider dataProvider, final HelixManager manager) { // Garbage collections for conditions where workflow context exists but config is missing. - Map<String, ZNRecord> contexts = dataProvider.getContexts(); - HelixDataAccessor accessor = manager.getHelixDataAccessor(); - HelixPropertyStore<ZNRecord> propertyStore = manager.getHelixPropertyStore(); + Set<String> existingWorkflowContexts; + try { + existingWorkflowContexts = new HashSet<>(dataProvider.getContexts().keySet()); + } catch (Exception e) { + LOG.warn( + "Exception occurred while creating a list of all existing contexts with missing config!", + e); Review comment: Done. ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org For additional commands, e-mail: reviews-h...@helix.apache.org