brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BROOKLYN-352) ConcurrentModificationException when using $brooklyn:entity
Date Tue, 22 Nov 2016 12:37:58 GMT

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

ASF GitHub Bot commented on BROOKLYN-352:
-----------------------------------------

Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/453#discussion_r89106124
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalEntityManager.java
---
    @@ -212,13 +213,41 @@ public EntityTypeRegistry getEntityTypeRegistry() {
     
         @Override
         public Iterable<Entity> getAllEntitiesInApplication(Application application)
{
    +        // To fix https://issues.apache.org/jira/browse/BROOKLYN-352, we need to synchronize
on
    +        // preRegisteredEntitiesById and preManagedEntitiesById while iterating over
them (because
    +        // they are synchronizedMaps). entityProxiesById is a ConcurrentMap, so no need
to 
    +        // synchronize on that.
    +        // Only synchronize on one at a time, to avoid the risk of deadlock.
    +        
             Predicate<Entity> predicate = EntityPredicates.applicationIdEqualTo(application.getId());
    -        Iterable<Entity> allentities = Iterables.concat(preRegisteredEntitiesById.values(),
preManagedEntitiesById.values(), entityProxiesById.values());
    -        Iterable<Entity> result = Iterables.filter(allentities, predicate);
    -        return ImmutableSet.copyOf(Iterables.transform(result, new Function<Entity,
Entity>() {
    -            @Override public Entity apply(Entity input) {
    -                return Entities.proxy(input);
    -            }}));
    +        Set<Entity> result = Sets.newLinkedHashSet();
    +        
    +        synchronized (preRegisteredEntitiesById) {
    --- End diff --
    
    Maybe it would be worth making `preRegisteredEntitiesById` and `preManagedEntitiesById`
private, and providing access to them with code like this loop, but put into a `protected`
method.  At the moment it's not impossible that some derived class in future would again use
one of the maps but forget the synchronization. 


> ConcurrentModificationException when using $brooklyn:entity
> -----------------------------------------------------------
>
>                 Key: BROOKLYN-352
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-352
>             Project: Brooklyn
>          Issue Type: Bug
>            Reporter: Svetoslav Neykov
>
> Got the following exception when running a fairly complex blueprint on a cpu starved
machine. Looking at the sources and the javadoc makes sense - we should guard iterating over
the entities with a synchronized block.
> From Collections.synchronizedMap:
> {noformat}
>      * It is imperative that the user manually synchronize on the returned
>      * map when iterating over any of its collection views:
> {noformat}
> {noformat}
> Failed after 13ms: Execution failed, invocation error for launching VanillaSoftwareProcessImpl{id=w4ixqlmhdh}:
Error resolving config shell.env.KUBERNETES_URL, $brooklyn:entity("kubernetes-master").attributeWhenReady("kubernetes.url"),
in org.apache.brooklyn.util.core.task.BasicExecutionContext@1d028d95([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=w4ixqlmhdh}],
LocalManagementContext[i5xdJAZa-yAstcnrg]]): org.apache.brooklyn.util.exceptions.PropagatedRuntimeException:
ConcurrentModificationException
> java.lang.IllegalStateException: Execution failed, invocation error for launching VanillaSoftwareProcessImpl{id=w4ixqlmhdh}:
Error resolving config shell.env.KUBERNETES_URL, $brooklyn:entity("kubernetes-master").attributeWhenReady("kubernetes.url"),
in org.apache.brooklyn.util.core.task.BasicExecutionContext@1d028d95([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=w4ixqlmhdh}],
LocalManagementContext[i5xdJAZa-yAstcnrg]]): org.apache.brooklyn.util.exceptions.PropagatedRuntimeException:
ConcurrentModificationException
> 	at org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper.logWithDetailsAndThrow(ScriptHelper.java:387)
> 	at org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper.executeInternal(ScriptHelper.java:370)
> 	at org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper$8.call(ScriptHelper.java:287)
> 	at org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper$8.call(ScriptHelper.java:285)
> 	at org.apache.brooklyn.util.core.task.DynamicSequentialTask$DstJob.call(DynamicSequentialTask.java:359)
> 	at org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.IllegalArgumentException: Error resolving config shell.env.KUBERNETES_URL,
$brooklyn:entity("kubernetes-master").attributeWhenReady("kubernetes.url"), in org.apache.brooklyn.util.core.task.BasicExecutionContext@1d028d95([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=w4ixqlmhdh}],
LocalManagementContext[i5xdJAZa-yAstcnrg]]): org.apache.brooklyn.util.exceptions.PropagatedRuntimeException:
ConcurrentModificationException
> 	at org.apache.brooklyn.util.core.task.ValueResolver.getMaybeInternal(ValueResolver.java:411)
> 	at org.apache.brooklyn.util.core.task.ValueResolver.getMaybe(ValueResolver.java:257)
> 	at org.apache.brooklyn.util.core.task.ValueResolver.get(ValueResolver.java:250)
> 	at org.apache.brooklyn.util.core.task.Tasks.resolveValue(Tasks.java:147)
> 	at org.apache.brooklyn.core.config.BasicConfigKey.resolveValue(BasicConfigKey.java:355)
> 	at org.apache.brooklyn.core.config.BasicConfigKey.extractValue(BasicConfigKey.java:340)
> 	at org.apache.brooklyn.core.config.SubElementConfigKey.extractValue(SubElementConfigKey.java:48)
> 	at org.apache.brooklyn.core.config.internal.AbstractStructuredConfigKey.extractValue(AbstractStructuredConfigKey.java:111)
> 	at org.apache.brooklyn.core.config.internal.AbstractStructuredConfigKey.extractValue(AbstractStructuredConfigKey.java:124)
> 	at org.apache.brooklyn.core.entity.internal.EntityConfigMap.getConfigImpl(EntityConfigMap.java:139)
> 	at org.apache.brooklyn.core.entity.internal.EntityConfigMap.getConfig(EntityConfigMap.java:113)
> 	at org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl.getConfig(AbstractConfigMapImpl.java:50)
> 	at org.apache.brooklyn.core.entity.AbstractEntity$BasicConfigurationSupport.get(AbstractEntity.java:1213)
> 	at org.apache.brooklyn.core.entity.AbstractEntity.getConfig(AbstractEntity.java:1299)
> 	at org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver.getShellEnvironment(AbstractSoftwareProcessSshDriver.java:348)
> 	at org.apache.brooklyn.entity.software.base.VanillaSoftwareProcessSshDriver.getShellEnvironment(VanillaSoftwareProcessSshDriver.java:147)
> 	at org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver.execute(AbstractSoftwareProcessSshDriver.java:265)
> 	at org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper.executeInternal(ScriptHelper.java:366)
> 	... 8 more
> Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: ConcurrentModificationException
> 	at org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:129)
> 	at org.apache.brooklyn.util.time.Durations.get(Durations.java:63)
> 	at org.apache.brooklyn.util.time.Durations.get(Durations.java:68)
> 	at org.apache.brooklyn.util.core.task.ValueResolver.getMaybeInternal(ValueResolver.java:348)
> 	... 25 more
> Caused by: java.util.concurrent.ExecutionException: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException:
ConcurrentModificationException
> 	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
> 	at java.util.concurrent.FutureTask.get(FutureTask.java:188)
> 	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
> 	at org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:361)
> 	at org.apache.brooklyn.util.time.Durations.get(Durations.java:43)
> 	... 27 more
> Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: ConcurrentModificationException
> 	at org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:129)
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.BrooklynDslDeferredSupplier.get(BrooklynDslDeferredSupplier.java:136)
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent$AttributeWhenReady.newTask(DslComponent.java:261)
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.BrooklynDslDeferredSupplier.get(BrooklynDslDeferredSupplier.java:128)
> 	at org.apache.brooklyn.util.core.task.ValueResolver$2.call(ValueResolver.java:334)
> 	... 6 more
> Caused by: java.util.concurrent.ExecutionException: java.util.ConcurrentModificationException
> 	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
> 	at java.util.concurrent.FutureTask.get(FutureTask.java:188)
> 	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
> 	at org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:361)
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.BrooklynDslDeferredSupplier.get(BrooklynDslDeferredSupplier.java:129)
> 	... 9 more
> Caused by: java.util.ConcurrentModificationException
> 	at java.util.WeakHashMap$HashIterator.nextEntry(WeakHashMap.java:882)
> 	at java.util.WeakHashMap$ValueIterator.next(WeakHashMap.java:909)
> 	at com.google.common.collect.Iterators$5.next(Iterators.java:553)
> 	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:646)
> 	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
> 	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
> 	at com.google.common.collect.TransformedIterator.hasNext(TransformedIterator.java:43)
> 	at com.google.common.collect.ImmutableSet.copyOf(ImmutableSet.java:314)
> 	at com.google.common.collect.ImmutableSet.copyOf(ImmutableSet.java:300)
> 	at org.apache.brooklyn.core.mgmt.internal.LocalEntityManager.getAllEntitiesInApplication(LocalEntityManager.java:218)
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent$EntityInScopeFinder.call(DslComponent.java:127)
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent$EntityInScopeFinder.call(DslComponent.java:96)
> 	... 6 more
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message