atmosphere icon indicating copy to clipboard operation
atmosphere copied to clipboard

Growing number of broadcaster threads

Open nite23 opened this issue 14 years ago • 5 comments

I create a new broadcaster with a unique ID for every new client. I track clients by saving a cookie with broadcaster ID. I programmatically set up shared thread pools for every new broadcaster, as per the wiki guide.

broadcasterLifeCyclePolicy is set to IDLE_DESTROY in web.xml, with idle time 35000 ms.

The problem is, as new clients connect, there is constantly a growing number of threads that never get removed, even when clients disconnect and idle timeout expires.

Thread dump shows hundreds of threads with names like pool-21426-thread-1 that are waiting indefinitely.

I use Jersey, long-polling transport, glassfish 3.1.2.2, latest snapshot of atmosphere.

There was no issue with atmosphere 1.0.2

nite23 avatar Oct 29 '12 12:10 nite23

@nite23 Which version are you using to reproduce the issue? Also please attach the thread dump if you can. Thanks

jfarcand avatar Oct 29 '12 12:10 jfarcand

@nite23 To be more specific, you use 1.1.0-SNAPSHOT or 1.0.3-SNAPSHOT?

jfarcand avatar Oct 29 '12 12:10 jfarcand

I use 1.1.0-SNAPSHOT

here's the dump: http://files.internetplus.cz/dump.txt

nite23 avatar Oct 29 '12 13:10 nite23

OK, I fail to reproduce this issue using 1.1-SNAPSHOT and this test case:

    @Test
    public void testBroadcasterEmptyDestroy() throws InterruptedException {
        final CountDownLatch latch = new CountDownLatch(1);
        final AtomicReference<Boolean> deleted = new AtomicReference<Boolean>();
        BroadcasterListener l = new BroadcasterListener() {
            @Override
            public void onPostCreate(Broadcaster b) {
            }

            @Override
            public void onComplete(Broadcaster b) {
            }

            @Override
            public void onPreDestroy(Broadcaster b) {
                deleted.set(Boolean.TRUE);
                latch.countDown();
            }
        };
        BroadcasterFactory.getDefault().addBroadcasterListener(l).get("/b1")
                .setBroadcasterLifeCyclePolicy(new BroadcasterLifeCyclePolicy.Builder()
                        .policy(BroadcasterLifeCyclePolicy.ATMOSPHERE_RESOURCE_POLICY.IDLE_DESTROY)
                .idleTime(5, TimeUnit.SECONDS).build());

        latch.await(10, TimeUnit.SECONDS);

        assertTrue(deleted.get());
    }

jfarcand avatar Oct 29 '12 18:10 jfarcand

Fixed by #717

jfarcand avatar Nov 01 '12 13:11 jfarcand