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

kevin yang commented on ZOOKEEPER-4309:
---------------------------------------

I have some idea on threadpool. Its spinning routine that called getTask always 
try to get or else blocked itself until pool accept a closed signal.

 
{code:java}
// code placeholderprivate Runnable getTask() {
    boolean timedOut = false; // Did the last poll() time out?

    for (;;) {
        int c = ctl.get();
        int rs = runStateOf(c);

        // Check if queue empty only if necessary.
        if (rs >= SHUTDOWN && (rs >= STOP || workQueue.isEmpty())) {  //exit 
once accept stop
            decrementWorkerCount();
            return null;
        }

        int wc = workerCountOf(c);

        // Are workers subject to culling?
        boolean timed = allowCoreThreadTimeOut || wc > corePoolSize;

        if ((wc > maximumPoolSize || (timed && timedOut))
            && (wc > 1 || workQueue.isEmpty())) {
            if (compareAndDecrementWorkerCount(c))
                return null;
            continue;
        }

        try {
            Runnable r = timed ?
                workQueue.poll(keepAliveTime, TimeUnit.NANOSECONDS) :
                workQueue.take();     //that block itself within core thread
            if (r != null)
                return r;
            timedOut = true;
        } catch (InterruptedException retry) {
            timedOut = false;
        }
    }
}
{code}

> QuorumCnxManager's ListenerHandler thread leak
> ----------------------------------------------
>
>                 Key: ZOOKEEPER-4309
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4309
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: server
>    Affects Versions: 3.6.3, 3.7.0
>            Reporter: Francesco Nigro
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> QuorumCnxManager::Listener::run is creating a 
> Executors.newFixedThreadPool(addresses.size()) without shutting it down after 
> ListenerHandler task has been completed causing it to leak.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to