pzhdfy commented on issue #6690: bugfix: when building materialized-view, if 
taskCount>1, may cause concurrentModificationException
URL: https://github.com/apache/incubator-druid/pull/6690#issuecomment-459931967
 
 
   Yes, this is guarded by taskLock .
   
   This is just the WRONG USE of hashmap.
   
   if we remove an entry  from a hashmap  by remove(key), while iterating it,  
this will throw a concurrentModificationException, even in a single thread.
   
   
![image](https://user-images.githubusercontent.com/2594619/52159446-ccf9db80-26df-11e9-9b98-fd9e735f7989.png)
   
   
ref:https://stackoverflow.com/questions/602636/concurrentmodificationexception-and-a-hashmap
   
   ```java
   for (Map.Entry<Interval, HadoopIndexTask> entry : runningTasks.entrySet()) {
           Optional<TaskStatus> taskStatus = 
taskStorage.getStatus(entry.getValue().getId());
           if (!taskStatus.isPresent() || !taskStatus.get().isRunnable()) {
             runningTasks.remove(entry.getKey());
             runningVersion.remove(entry.getKey());
           }
         }
   ```

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to