You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Shai Erera <se...@gmail.com> on 2012/02/23 07:33:09 UTC

Can we add isDaemon check to LTC.threadCleanup?

Hi

I think that if a thread is daemon, but still running, LTC.threadCleanup
should not report it. What do you think?

Shai

Re: Can we add isDaemon check to LTC.threadCleanup?

Posted by Dawid Weiss <da...@cs.put.poznan.pl>.
> It's very stupid that it does that ...

Looks like a bug in their code -- submit a patch, they'll be happy.

Dawid

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Can we add isDaemon check to LTC.threadCleanup?

Posted by Shai Erera <se...@gmail.com>.
I investigated Jetty's QueuedThreadPool code more and I think that I
spotted the bug.

In doStop(), it iterates on all running threads, interrupting them. It does
that in a loop (100 cycles, sleeping for 100*i in each cycle) until all
threads are done. The problem is that one of the threads that it tries to
interrupt is itself (!!), but it cannot interrupt itself, and therefore the
list of threads never gets empty, and it keeps on iterating. I debug-traced
it and I believe that's the problem.

It's very stupid that it does that ...

Shai

On Thu, Feb 23, 2012 at 11:45 AM, Dawid Weiss
<da...@cs.put.poznan.pl>wrote:

> > It's not a test case in Lucene, but rather my tests that extend
> > LuceneTestCase :). And I'm sure many of Solr's tests cause these prints
> too,
> > though I didn't verify.
>
> Yep, they definitely do. I'm working on serious refactorings of
> LuceneTestCase and I'll try to pulled thread management from there
> anyway. Once I get there I'll see what we can do about jetty. I recall
> we had jetty tests throw some lingering threads at us in Carrot2 but
> we somehow managed to shut it down gracefully.
>
> Dawid
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

Re: Can we add isDaemon check to LTC.threadCleanup?

Posted by Dawid Weiss <da...@cs.put.poznan.pl>.
> It's not a test case in Lucene, but rather my tests that extend
> LuceneTestCase :). And I'm sure many of Solr's tests cause these prints too,
> though I didn't verify.

Yep, they definitely do. I'm working on serious refactorings of
LuceneTestCase and I'll try to pulled thread management from there
anyway. Once I get there I'll see what we can do about jetty. I recall
we had jetty tests throw some lingering threads at us in Carrot2 but
we somehow managed to shut it down gracefully.

Dawid

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Can we add isDaemon check to LTC.threadCleanup?

Posted by Shai Erera <se...@gmail.com>.
Hi Dawid,

It's not a test case in Lucene, but rather my tests that extend
LuceneTestCase :). And I'm sure many of Solr's tests cause these prints
too, though I didn't verify.

Shai

On Thu, Feb 23, 2012 at 11:19 AM, Dawid Weiss
<da...@cs.put.poznan.pl>wrote:

> > I use a Jetty server instance in my tests, and LTC almost always reports
> > that the 'qtp' threads are left open. 'qtp' are the prefix name of
> Jetty's
> > QueuedThreadPool threads. QueuedThreadPool has two defaults:
>
> Yeah... I don't have the time for this right now, but it should just
> close if possible. I don't like the idea of making exceptions in the
> ltc just because jetty doesn't clean up after itself :)
>
> Can you create an issue and specify which test case causes this to
> happen? I'll take a look when I get a spare moment.
>
> Dawid
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

Re: Can we add isDaemon check to LTC.threadCleanup?

Posted by Dawid Weiss <da...@cs.put.poznan.pl>.
> I use a Jetty server instance in my tests, and LTC almost always reports
> that the 'qtp' threads are left open. 'qtp' are the prefix name of Jetty's
> QueuedThreadPool threads. QueuedThreadPool has two defaults:

Yeah... I don't have the time for this right now, but it should just
close if possible. I don't like the idea of making exceptions in the
ltc just because jetty doesn't clean up after itself :)

Can you create an issue and specify which test case causes this to
happen? I'll take a look when I get a spare moment.

Dawid

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Can we add isDaemon check to LTC.threadCleanup?

Posted by Shai Erera <se...@gmail.com>.
I use a Jetty server instance in my tests, and LTC almost always reports
that the 'qtp' threads are left open. 'qtp' are the prefix name of Jetty's
QueuedThreadPool threads. QueuedThreadPool has two defaults:

1) It is not daemon, therefore its PoolThreads are not set daemon too
2) It defaults to keep idle threads for 60 seconds around

In real-life these two settings make sense, but in tests, when I know that
I call server.stop only after all my tasks have completed, it's annoying.

When you call server.stop() followed by server.join(), it calls qtp.stop()
which interrupts all running PoolThreads. I'm not sure if there's a bug in
QueuedThreadPool's impl (or maybe PoolThread's impl), but I can tell for
sure that the JVM process keeps running for ~60 seconds, even though the
Socket and port have been released.

So I wrote this code in my tests that start a Server instance:

Server s = new Server();
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setDaemon(true); // I don't mind it'll be daemon in tests.
qtp.setMaxIdleTimeMs(0); // when a thread becomes idle, kill it
s.setThreadPool(qtp);

Yet, sometimes even that's not enough and LTC's afterClass is called before
the PoolThread dies. So I'm just thinking that if LTC would ignore daemon
threads, the annoying messages will be gone :).

It's not a big deal, just annoying to see these prints, and wasting so much
time trying to make them go away :).

Shai

On Thu, Feb 23, 2012 at 9:14 AM, Dawid Weiss
<da...@cs.put.poznan.pl>wrote:

> I think it should be closed gracefully, even if it's a daemon thread.
> Which thread do you have in mind?
>
> Dawid
>
> On Thu, Feb 23, 2012 at 7:33 AM, Shai Erera <se...@gmail.com> wrote:
> > Hi
> >
> > I think that if a thread is daemon, but still running, LTC.threadCleanup
> > should not report it. What do you think?
> >
> > Shai
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

Re: Can we add isDaemon check to LTC.threadCleanup?

Posted by Dawid Weiss <da...@cs.put.poznan.pl>.
I think it should be closed gracefully, even if it's a daemon thread.
Which thread do you have in mind?

Dawid

On Thu, Feb 23, 2012 at 7:33 AM, Shai Erera <se...@gmail.com> wrote:
> Hi
>
> I think that if a thread is daemon, but still running, LTC.threadCleanup
> should not report it. What do you think?
>
> Shai

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org