Too many blocked threads with 0.7.2 and EMPTY_DESTROY

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Too many blocked threads with 0.7.2 and EMPTY_DESTROY

irosso
We are using atmosphere 0.7.2 and the atmosphere threads are hanging forever, although we use ATMOSPHERE_RESOURCE_POLICY.EMPTY_DESTROY(see the attached thread dump).
This is an extract from our implementation of AtmosphereGwtHandler:

        public static final String TRANSPORT_PARAMETER = "tr";
        private final static int TIMEOUT = 30000;
        private final static int ZERO_TIMEOUT = 1;
       
        @Override
        public int doComet(GwtAtmosphereResource resource) throws ServletException, IOException {

                String topic = resource.getRequest().getPathInfo();
                if (topic != null && topic.length() > 1) {
                        topic = topic.startsWith("/") ? topic.substring(1) : topic;
                }

                if (!isLoggedIn(resource)) {
                        return ZERO_TIMEOUT;
                }

                if (resource.getAtmosphereResource() instanceof AtmosphereEventLifecycle) {
                        final AtmosphereEventLifecycle ael = (AtmosphereEventLifecycle) resource.getAtmosphereResource();
                        ael.addEventListener(new EventsLogger());
                        ael.addEventListener(new GlobalBroadcasterEventListener());
                }

                try {
                        final Broadcaster broadcaster = BroadcasterFactory.getBroadcaster(topic, true);
                        resource.getAtmosphereResource().setBroadcaster(broadcaster);
                } catch (ClassNotFoundException e) {
                        LOG.error("Failed to get broadcaster", e);
                }
                return TIMEOUT;
        }

The BroadcasterFactory implementation:
public class BroadcasterFactory {
       
        private BroadcasterFactory() {
                super();
        }

        public static Broadcaster getBroadcaster(String channelName, boolean createIfNotExisting) throws ClassNotFoundException {
                final String className = AtmosphereServlet.getDefaultBroadcasterClassName();
                @SuppressWarnings("unchecked")
                final Class<? extends Broadcaster> broadcasterClass = (Class<? extends Broadcaster>) Class.forName(className);
                final Broadcaster broadcaster = org.atmosphere.cpr.BroadcasterFactory.getDefault().lookup(
                                broadcasterClass, channelName, createIfNotExisting);
                return broadcaster;
        }

}
The configuration for the atmosphere:
          <servlet>
                <description>AtmosphereServlet</description>
                <servlet-name>AtmosphereServlet</servlet-name>
                <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
                <init-param>
                        <param-name>com.sun.jersey.config.property.packages</param-name>
                        <param-value>com.mycompany.soda.web.chat,com.mycompany.soda.web.events</param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.useWebSocket</param-name>
                        <param-value>true</param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.useNative</param-name>
                        <param-value>true</param-value>
                </init-param>
                <init-param>
                        <param-name>heartbeat</param-name>
                        <param-value>30000</param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.cpr.broadcasterClass</param-name>
                        <param-value>com.mycompany.soda.atmosphere.SingleConnectionRedisBroadcaster</param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.cpr.broadcasterLifeCyclePolicy</param-name>
                        <param-value>EMPTY_DESTROY</param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.cpr.CometSupport.maxInactiveActivity</param-name>
                        <param-value>30000</param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
        </servlet>

Thank you for your help!
Irina
tdump.txt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Too many blocked threads with 0.7.2 and EMPTY_DESTROY

irosso
irosso wrote
We are using atmosphere 0.7.2 and the atmosphere threads are hanging forever, although we use ATMOSPHERE_RESOURCE_POLICY.EMPTY_DESTROY(see the attached thread dump).
I've attached another thread dump which shows that we have lots of these blocked threads, i can also see  these threads "Atmosphere-BroadcasterConfig-0" hanging in debugger.

Also, when we use EMPTY_DESTROY or IDLE_DESTROY following Exceptions are thrown:

java.lang.IllegalStateException: This Broadcaster has been destroyed and cannot be used
at org.atmosphere.cpr.DefaultBroadcaster.removeAtmosphereResource(DefaultBroadcaster.java:741)
at org.atmosphere.cpr.DefaultBroadcasterFactory.removeAllAtmosphereResource(DefaultBroadcasterFactory.java:204)
at org.atmosphere.cpr.AsynchronousProcessor.destroyResource(AsynchronousProcessor.java:377)
at org.atmosphere.cpr.AsynchronousProcessor.cancelled(AsynchronousProcessor.java:424)
at org.atmosphere.container.TomcatCometSupport.cancelled(TomcatCometSupport.java:180)
at org.atmosphere.cpr.AsynchronousProcessor$1.run(AsynchronousProcessor.java:99)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:165)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)

jstack.txt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Too many blocked threads with 0.7.2 and EMPTY_DESTROY

jfarcand
Administrator
Salut,

ok dump response (I was out for awhile)....have you tried using atmosphere 0.8-SNAPSHOT? I'm not able to reproduce the issue, but I suspect I'm missing the scenario here.

Thanks

-- Jeanfrancois
Loading...