You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by "Hiranya Jayathilaka (JIRA)" <ji...@apache.org> on 2010/06/09 08:27:11 UTC

[jira] Commented: (SYNAPSE-659) MBeanRegistrar Is Not Thread Safe

    [ https://issues.apache.org/jira/browse/SYNAPSE-659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12876971#action_12876971 ] 

Hiranya Jayathilaka commented on SYNAPSE-659:
---------------------------------------------

In order to fix this, I'm going to synchronize the register and unregister methods in the registrar. Since the registrar is maintained as a singleton, it will ensure only one thread can invoke these methods at a time. Also since these methods are called only during the system initialization and shutdown, synchronizing them does not have an impact on the runtime performance.

> MBeanRegistrar Is Not Thread Safe
> ---------------------------------
>
>                 Key: SYNAPSE-659
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-659
>             Project: Synapse
>          Issue Type: Bug
>    Affects Versions: 1.2
>            Reporter: Hiranya Jayathilaka
>            Assignee: Hiranya Jayathilaka
>             Fix For: 2.0
>
>
> The MBeanRegistrar implementation used to register various MBeans, is not thread safe. The register method can be invoked by multiple threads at the same time with the same arguments.With a sufficient level of contention, the registrar may attempt to register the same MBean multiple times. This results in an exception like this:
> [2010-06-09 11:28:56,840]  WARN - MBeanRegistrar Error registering a MBean with name ' StatisticsView ' and category name ' StatisticsView' for JMX management
> javax.management.InstanceAlreadyExistsException: org.apache.synapse:Type=StatisticsView,Name=StatisticsView
> 	at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
> 	at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
> 	at org.apache.synapse.commons.jmx.MBeanRegistrar.registerMBean(MBeanRegistrar.java:51)
> 	at org.apache.synapse.aspects.statistics.StatisticsCollector.<init>(StatisticsCollector.java:36)
> 	at org.apache.synapse.aspects.statistics.StatisticsReporter.collectStatistics(StatisticsReporter.java:192)
> 	at org.apache.synapse.aspects.statistics.StatisticsReporter.reportForComponent(StatisticsReporter.java:56)
> 	at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:75)
> 	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
> 	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
> 	at org.apache.synapse.transport.nhttp.ServerWorker.processEntityEnclosingMethod(ServerWorker.java:349)
> 	at org.apache.synapse.transport.nhttp.ServerWorker.run(ServerWorker.java:239)
> 	at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> 	at java.lang.Thread.run(Thread.java:619)
> [2010-06-09 11:28:56,840]  WARN - MBeanRegistrar Error registering a MBean with name ' StatisticsView ' and category name ' StatisticsView' for JMX management
> javax.management.InstanceAlreadyExistsException: org.apache.synapse:Type=StatisticsView,Name=StatisticsView
> 	at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
> 	at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
> 	at org.apache.synapse.commons.jmx.MBeanRegistrar.registerMBean(MBeanRegistrar.java:51)
> 	at org.apache.synapse.aspects.statistics.StatisticsCollector.<init>(StatisticsCollector.java:36)
> 	at org.apache.synapse.aspects.statistics.StatisticsReporter.collectStatistics(StatisticsReporter.java:192)
> 	at org.apache.synapse.aspects.statistics.StatisticsReporter.reportForComponent(StatisticsReporter.java:56)
> 	at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:75)
> 	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
> 	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
> 	at org.apache.synapse.transport.nhttp.ServerWorker.processEntityEnclosingMethod(ServerWorker.java:349)
> 	at org.apache.synapse.transport.nhttp.ServerWorker.run(ServerWorker.java:239)
> 	at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> 	at java.lang.Thread.run(Thread.java:619)
> [2010-06-09 11:28:56,840]  WARN - MBeanRegistrar Error registering a MBean with name ' StatisticsView ' and category name ' StatisticsView' for JMX management
> javax.management.InstanceAlreadyExistsException: org.apache.synapse:Type=StatisticsView,Name=StatisticsView
> 	at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
> 	at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
> 	at org.apache.synapse.commons.jmx.MBeanRegistrar.registerMBean(MBeanRegistrar.java:51)
> 	at org.apache.synapse.aspects.statistics.StatisticsCollector.<init>(StatisticsCollector.java:36)
> 	at org.apache.synapse.aspects.statistics.StatisticsReporter.collectStatistics(StatisticsReporter.java:192)
> 	at org.apache.synapse.aspects.statistics.StatisticsReporter.reportForComponent(StatisticsReporter.java:56)
> 	at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:75)
> 	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
> 	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
> 	at org.apache.synapse.transport.nhttp.ServerWorker.processEntityEnclosingMethod(ServerWorker.java:349)
> 	at org.apache.synapse.transport.nhttp.ServerWorker.run(ServerWorker.java:239)
> 	at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> 	at java.lang.Thread.run(Thread.java:619)
> [2010-06-09 11:28:56,840]  WARN - MBeanRegistrar Error registering a MBean with name ' StatisticsView ' and category name ' StatisticsView' for JMX management
> In this case I engaged statistics on an endpoint and then loaded the ESB with Java bench using 30 concurrent threads.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org