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

Mike Drob commented on SOLR-16187:
----------------------------------

The thread that I highlighted was from the CloudSolrClient's internal thread 
pool - we try-with-resource create a CSC in the test, then CSC.close() calls 
shutdownAndAwaitTermination...

and awaitTermination certainly looks like it won't return until everything has 
reached the Terminated state.

No, hold on, it waits for the pool to reach terminated state, which doesn't 
necessarily mean that every thread is TERMINATED? Ok, this took me a long time 
to get, but I think I'm with you on it now. The worker task can be completed, 
which would decrement the worker count of the thread pool but the Thread would 
still be removing itself from the thread group which is something it does as 
part of termination, so it's technically still alive at that point.

So... we set a ThreadLeakLinger of 100ms and these should all go away?

> ExecutorUtil#awaitTermination shouldn't wait forever
> ----------------------------------------------------
>
>                 Key: SOLR-16187
>                 URL: https://issues.apache.org/jira/browse/SOLR-16187
>             Project: Solr
>          Issue Type: Bug
>            Reporter: Kevin Risden
>            Assignee: Kevin Risden
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> While looking at some of the other thread leak issues, found that 
> ExecutorUtil#awaitTermination is waiting basically forever:
> https://github.com/apache/solr/blob/main/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java#L98
> {code:java}
> public static void awaitTermination(ExecutorService pool) {
>     boolean shutdown = false;
>     while (!shutdown) {
>       try {
>         // Wait a while for existing tasks to terminate
>         shutdown = pool.awaitTermination(60, TimeUnit.SECONDS);
>       } catch (InterruptedException ie) {
>         // Preserve interrupt status
>         Thread.currentThread().interrupt();
>       }
>     }
>   }
> {code}
> Instead it should be possible to wait and then if still not shutdown then 
> interrupt the threads? ie: pool.shutdownNow() then another awaitTermination 
> to at least limit the termination time to 2*60 seconds?
> This would at least have some bound to shutting stuff down.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to