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-245) Deadlock from ControlledDynamicWebAppCluster, plus thread modifying attribute
Date Fri, 01 Apr 2016 11:12:25 GMT

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

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

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

    https://github.com/apache/brooklyn-server/pull/96#discussion_r58191767
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java ---
    @@ -1548,7 +1550,7 @@ public boolean unsubscribe(Entity producer, SubscriptionHandle handle)
{
          * @deprecated since 0.9.0; for internal use only
          */
         @Deprecated
    -    protected synchronized SubscriptionTracker getSubscriptionTracker() {
    +    protected SubscriptionTracker getSubscriptionTracker() {
    --- End diff --
    
    I think this existing code is ok, in terms of the deadlock encountered in BROOKLYN-245.
The `AttributeMap` should never call into `getSubscriptionTracker()`, so there will never
be a call to it while holding a lock on `AttributeMap.values`.
    
    In terms of calling `getSubscriptionContext()` while holding other locks (e.g. on `AbstractEntity.this`)
we should be ok: it will synchronize on `EntityManagementSupport.this` and will then call
into the management context's subscription manager, but that code should *never* call out
to alien code.
    
    It would be good to remove the `synchronized (AbstractEntity.this)` entirely, to have
simpler concurrency code. But we must be aware that the caller might already have synchronized
on the entity instance when calling `subscribe()`. So removing this synchronization doesn't
eliminate any deadlocks - instead we must be sure that synchronizing on the entity instance
won't risk deadlocks.
    
    As an aside, note that double-checked locking is broken if the field is not declared volatile.
    
    Given that, are you ok leaving the code as-is in this PR?


> Deadlock from ControlledDynamicWebAppCluster, plus thread modifying attribute
> -----------------------------------------------------------------------------
>
>                 Key: BROOKLYN-245
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-245
>             Project: Brooklyn
>          Issue Type: Bug
>            Reporter: Aled Sage
>
> With master (i.e. would also affect 0.9.0)...
> When running {{org.apache.brooklyn.qa.load.LoadTest}} several times, I hit the deadlock
below.
> The test deploys several apps concurrently, each using {{ControlledDynamicWebAppCluster}}
(via the Java-app {{SimulatedTheeTierApp}}). This deadlock could happen in other uses of {{ControlledDynamicWebAppCluster}},
or in other entities depending if/when they synchronize on the entity themselves.
> {noformat}
> Java stack information for the threads listed above:
> ===================================================
> "brooklyn-execmanager-H7Adif6C-157":
>         at org.apache.brooklyn.core.sensor.AttributeMap.asMap(AttributeMap.java:92)
>         - waiting to lock <0x00000007d3504b60> (a java.util.Collections$SynchronizedMap)
>         at org.apache.brooklyn.core.entity.AbstractEntity$BasicSensorSupport.getAll(AbstractEntity.java:1129)
>         at org.apache.brooklyn.core.entity.AbstractEntity.getAllAttributes(AbstractEntity.java:1003)
>         at org.apache.brooklyn.core.mgmt.rebind.dto.MementosGenerators.newEntityMementoBuilder(MementosGenerators.java:194)
>         at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.getMementoWithProperties(BasicEntityRebindSupport.java:69)
>         at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.getMemento(BasicEntityRebindSupport.java:61)
>         at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.getMemento(BasicEntityRebindSupport.java:1)
>         at org.apache.brooklyn.core.mgmt.rebind.PeriodicDeltaChangeListener.persistNowInternal(PeriodicDeltaChangeListener.java:417)
>         at org.apache.brooklyn.core.mgmt.rebind.PeriodicDeltaChangeListener.persistNowSafely(PeriodicDeltaChangeListener.java:352)
>         at org.apache.brooklyn.core.mgmt.rebind.PeriodicDeltaChangeListener.persistNowSafely(PeriodicDeltaChangeListener.java:346)
>         at org.apache.brooklyn.core.mgmt.rebind.PeriodicDeltaChangeListener$1$1.call(PeriodicDeltaChangeListener.java:215)
>         at org.apache.brooklyn.core.mgmt.rebind.PeriodicDeltaChangeListener$1$1.call(PeriodicDeltaChangeListener.java:1)
>         at org.apache.brooklyn.util.core.task.BasicExecutionManager$ScheduledTaskCallable$1.call(BasicExecutionManager.java:436)
>         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)
> "brooklyn-execmanager-H7Adif6C-16":
>         at org.apache.brooklyn.core.entity.AbstractEntity$BasicSubscriptionSupport.getSubscriptionContext(AbstractEntity.java:1488)
>         - waiting to lock <0x00000007d34abc20> (a org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppClusterImpl)
>         at org.apache.brooklyn.core.entity.AbstractEntity$BasicSensorSupport.emitInternal(AbstractEntity.java:1164)
>         at org.apache.brooklyn.core.entity.AbstractEntity.emitInternal(AbstractEntity.java:2021)
>         at org.apache.brooklyn.core.sensor.AttributeMap.update(AttributeMap.java:133)
>         at org.apache.brooklyn.core.sensor.AttributeMap.modify(AttributeMap.java:162)
>         - locked <0x00000007d3504b60> (a java.util.Collections$SynchronizedMap)
>         at org.apache.brooklyn.core.entity.AbstractEntity$BasicSensorSupport.modify(AbstractEntity.java:1106)
>         at org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic.updateMapSensorEntry(ServiceStateLogic.java:150)
>         at org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic.clearMapSensorEntry(ServiceStateLogic.java:102)
>         at org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceIndicatorsFromChildrenAndMembers.updateMapSensor(ServiceStateLogic.java:558)
>         at org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceIndicatorsFromChildrenAndMembers.onUpdated(ServiceStateLogic.java:477)
>         at org.apache.brooklyn.enricher.stock.AbstractAggregator$8.onEvent(AbstractAggregator.java:178)
>         at org.apache.brooklyn.core.mgmt.internal.LocalSubscriptionManager$2.run(LocalSubscriptionManager.java:244)
>         at org.apache.brooklyn.util.concurrent.CallableFromRunnable.call(CallableFromRunnable.java:43)
>         at org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
>         at org.apache.brooklyn.util.core.task.SingleThreadedScheduler$1.call(SingleThreadedScheduler.java:116)
>         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)
> "brooklyn-execmanager-H7Adif6C-4":
>         at java.util.Collections$SynchronizedMap.get(Collections.java:2037)
>         - waiting to lock <0x00000007d3504b60> (a java.util.Collections$SynchronizedMap)
>         at org.apache.brooklyn.core.sensor.AttributeMap.getValue(AttributeMap.java:200)
>         at org.apache.brooklyn.core.sensor.AttributeMap.getValue(AttributeMap.java:206)
>         at org.apache.brooklyn.core.entity.AbstractEntity$BasicSensorSupport.get(AbstractEntity.java:1038)
>         at org.apache.brooklyn.core.entity.AbstractEntity.getAttribute(AbstractEntity.java:946)
>         at org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppClusterImpl.getCluster(ControlledDynamicWebAppClusterImpl.java:194)
>         - locked <0x00000007d34abc20> (a org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppClusterImpl)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:606)
>         at org.apache.brooklyn.core.objs.proxy.EntityProxyImpl.invoke(EntityProxyImpl.java:213)
>         at com.sun.proxy.$Proxy57.getCluster(Unknown Source)
>         at org.apache.brooklyn.qa.load.SimulatedTheeTierApp.init(SimulatedTheeTierApp.java:102)
>         at org.apache.brooklyn.core.objs.proxy.InternalEntityFactory$1.run(InternalEntityFactory.java:327)
>         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>         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)
> Found 1 deadlock.
> {noformat}



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

Mime
View raw message