[
https://issues.apache.org/jira/browse/SOLR-16187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17581592#comment-17581592
]
Michael Gibney commented on SOLR-16187:
---------------------------------------
{quote}I can't think of any other way that this thread pool would still be
running after the test has already completed.
{quote}
I'm certain this is possible and perfectly normal actually:
https://issues.apache.org/jira/browse/SOLR-15660?focusedCommentId=17534560#comment-17534560
I had previously been thinking that this only applied to cases where the
threads are introduced within the test code, not by the test framework – it's
not immediately clear to me which is the case with the above stacktrace. But
the conclusion in the above-linked comment (which I'm 100% confident of,
despite how counterintuitive it seems) is that ThreadLeakLingering is
absolutely necessary to avoid these false positives – and notably, threads
still being detectable after {{awaitTermination()}} manifest exactly the stack
trace pasted above (i.e., {{{}tryTerminate(){}}}, etc...).
Really I think we should restore a blanket ThreadLeakLingering, basically
reverting SOLR-15660 – 10s was too long, but 1s should suffice. Any of the
{{{}@ThreadLeakLingering(linger = 10){}}}, or 30, etc. are effective in units
of 100ms, so will be "rounded up", and the fact that they're there as 10, 30,
etc. is misleading.
I'm glad you brought this up again Mike, it's been hanging in the back of my
mind ... these issues don't crop up often, but they're definitely spurious and
they definitely contribute needlessly to overall test noise.
> 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: 40m
> 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]