[
https://issues.apache.org/jira/browse/ZOOKEEPER-4309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17354802#comment-17354802
]
Francesco Nigro edited comment on ZOOKEEPER-4309 at 6/1/21, 4:54 AM:
---------------------------------------------------------------------
There are other parts in the zookeeper source code where a similar pattern is
used and executor::shutdown is called to save the leak to happen.
The leak happen while halting QuorumCnxManager: listenerHandlers task can be
already completed or are going to complete on halt, but the executorservice's
thread are still alive, and given that are non-daemon, are GC roots and won't
be garbage collected.
An ExecutorService which non-daemon threads are still alive prevent a main
thread to complete.
I can write a test program to better show what I mean.
was (Author: nigrofranz):
There are other parts in the zookeeper source code where a similar pattern is
used and executor::shutdown is called to save the leak to happen.
The leak happen while halting QuorumCnxManager:
listenerHandlers.forEach(executor::submit) can complete or not but the
executorservice's thread are still alive, and given that are non-daemon, are GC
roots and won't be garbage collected.
An ExecutorService which non-daemon threads are still alive prevent a main
thread to complete.
I can write a test program to better show what I mean.
> 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: Minor
> Labels: pull-request-available
> Time Spent: 40m
> 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)