Aled Sage created BROOKLYN-285:
----------------------------------

             Summary: Dangling reference in Propagator.producer: can cause 
subscription to self, and infinite subscription loop
                 Key: BROOKLYN-285
                 URL: https://issues.apache.org/jira/browse/BROOKLYN-285
             Project: Brooklyn
          Issue Type: Bug
    Affects Versions: 0.9.0
            Reporter: Aled Sage


When the "producer" entity of a Propagator enricher is unmanaged, it can cause 
rebind to resolve the dangling reference value as {{null}}. In 0.9.0, that is 
treated as the producer being "self". This can cause an infinite loop, where 
the Propagator subscribes to its own sensor, and every time its sensor changes 
it resets the sensor value.

To reproduce, deploy this app:

{noformat}
location: localhost
services:
- type: org.apache.brooklyn.entity.stock.BasicApplication
  brooklyn.children:
  - type: org.apache.brooklyn.entity.machine.MachineEntity
{noformat}

And programmatically add a Propagator enricher to the top-level app, such as:

{noformat}
appId = "u4VDoIOa";
childId = "LPYT4g27";
sensor = org.apache.brooklyn.core.sensor.Sensors.newSensor(String.class, 
"host.name");
app = mgmt.getEntityManager().getEntity(appId);
child = mgmt.getEntityManager().getEntity(childId);
app.enrichers().add(org.apache.brooklyn.api.sensor.EnricherSpec.create(org.apache.brooklyn.enricher.stock.Propagator.class)
    .configure("enricher.producer", child)
    .configure("enricher.propagating.inclusions", 
com.google.common.collect.ImmutableList.of(sensor)));
{noformat}

Then unmanange the child entity (e.g. via the advanced tab in the web-console), 
and restart Brooklyn.

The CPU goes through the roof, and the debug log shows log messages like:

{noformat}
2016-05-31 09:02:22,599 DEBUG o.a.b.c.m.i.LocalSubscriptionManager 
[brooklyn-execmanager-gfOvVoKq-3]: 388000 events for subscriber 
Subscription[qF9YFEBA;BasicApplicationImpl{id=u4VDoIOa}@u4VDoIOa:host.name]
{noformat}




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

Reply via email to