[ 
https://issues.apache.org/jira/browse/KYLIN-2509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15941313#comment-15941313
 ] 

liyang commented on KYLIN-2509:
-------------------------------

The {{booking}} is a ConcurrentHashMap. Its {{values()}} should be immune from 
ConcurrentModificationException.

{code}
    /**
     * Returns a {@link Collection} view of the values contained in this map.
     * The collection is backed by the map, so changes to the map are
     * reflected in the collection, and vice-versa.  The collection
     * supports element removal, which removes the corresponding
     * mapping from this map, via the <tt>Iterator.remove</tt>,
     * <tt>Collection.remove</tt>, <tt>removeAll</tt>,
     * <tt>retainAll</tt>, and <tt>clear</tt> operations.  It does not
     * support the <tt>add</tt> or <tt>addAll</tt> operations.
     *
     * <p>The view's <tt>iterator</tt> is a "weakly consistent" iterator
     * that will never throw {@link ConcurrentModificationException},
     * and guarantees to traverse elements as they existed upon
     * construction of the iterator, and may (but is not guaranteed to)
     * reflect any modifications subsequent to construction.
     */
    public Collection<V> values()
{code}

> Unsafe iteration over booking in MemoryBudgetController#tryFreeUp
> -----------------------------------------------------------------
>
>                 Key: KYLIN-2509
>                 URL: https://issues.apache.org/jira/browse/KYLIN-2509
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Ted Yu
>            Priority: Minor
>
> {code}
>         for (ConsumerEntry entry : booking.values()) {
>             int mb = entry.consumer.freeUp(gap);
>             if (mb > 0) {
>                 lock.lock();
>                 try {
>                     updateBookingWithDelta(entry.consumer, -mb);
> {code}
> In updateBookingWithDelta, booking may be modified, leading to concurrent 
> modification.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to