You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@excalibur.apache.org by Marcus Crafter <cr...@managesoft.com> on 2004/11/16 19:13:52 UTC
ThreadManager.dispose() issue
Hi Guys,
I think I've tracked down part of the cornerstone threadmanager
dispose() issue described in my previous email, but I'm not sure how to
handle it - any ideas appreciated :)
Cornerstone thread manager uses at a lower level (via
SoftResourceLimitingPool) o.a.a.excalibur.pool.DefaultPool.
When disposing the ThreadManager, it passes on the request to dispose to
the underyling thread pool manager, which is below.
The method (in o.a.a.excalibur.pool.DefaultPool):
public final void dispose()
{
try
{
m_mutex.acquire();
try
{
while( m_ready.size() > 0 )
{
this.removePoolable( (Poolable)m_ready.remove() );
}
}
finally
{
m_mutex.release();
}
}
catch( Exception e )
{
if( getLogger().isWarnEnabled() )
{
getLogger().warn( "Caught an exception disposing of pool", e );
}
}
this.m_disposed = true;
}
From what I can see there something is missing.
The 'm_ready' field contains the poolables ready to be assigned, however
when poolables are in use, they're taken out of the 'm_ready' buffer,
and put into an 'm_active' list, until returned (see
DefaultPool.get()/put()).
So, if a dispose() comes along while poolables are out in use (and are
hence not in the m_ready buffer but in the m_active list) then they are
skipped and not disposed.
What do you guys think?
The problem I'm finding is how to actually dispose them properly, since
at the level of DefaultPool, we don't even know they're threads.
I added another loop inside the dispose():
while( m_active.size() > 0 )
{
this.removePoolable( (Poolable)m_active.remove( 0 ) );
}
but that gave me an exception:
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 4.032 sec
java.lang.IllegalStateException: Attempted to recycle dead thread.
at
org.apache.excalibur.thread.impl.WorkerThread.recycleThread(WorkerThread.java:211)
at
org.apache.excalibur.thread.impl.WorkerThread.run(WorkerThread.java:194)
This seems to be happening simply because the WorkerThread is being
disposed() while the run() on the thread is being done. At the end of
the run(), a recycle of the thread is attempted - which causes the
exception to be thrown due to the dispose() invalidating the state of
the WorkerThread.
So for the moment I'm kind-of stuck on how to fix it - any ideas guys?
Cheers,
Marcus
Berin Loritsch wrote:
> Marcus Crafter wrote:
>
>>Hi All,
>>
>>Marcus Crafter wrote:
>>
>>
>>>And the last one "[FATAL ERROR] Writing event to closed stream" seems
>>>to happen often, but doesn't have any noticable effect on the test
>>>case results.
>>
>>
>>Bit more information on this one.
>>
>>The error is actually coming from within logkit, and from what I can see
>>is due to:
>
>
> <snip/>
>
>>ie. the LogKitLoggerManager being closed before the Cornerstone
>>ThreadManager has finished shutting down all of the thread pools - and
>>once the logkit manager is shut down, the events are marked as being
>>written to a closed stream.
>>
>>Should the Cornerstone Thread Manager block until all thread pools have
>>been cleaned up?
>
>
> It makes sense.
>
--
.....
,,$$$$$$$$$, Marcus Crafter
;$' '$$$$: Computer Systems Engineer
$: $$$$: ManageSoft Corporation
$ o_)$$$: Frankfurt am Main, Germany
;$, _/\ &&:'
' /( &&&
\_&&&&'
&&&&.
&&&&&&&:
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/
Re: ThreadManager.dispose() issue
Posted by Marcus Crafter <cr...@managesoft.com>.
Hi Peter,
Marcus Crafter wrote:
> Thanks for that information - didn't realize there were other issues in
> that space as well that people knew about.
>
> I'll take a look at the spice threadpool package as you suggested.
>
> Are there also spice equivalents of cornerstone connection and socket
> manager, that already use the thread manager you mention?
Found it - spice netserve. Looking into it now. Thanks again for your help.
Cheers,
Marcus
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/
Re: ThreadManager.dispose() issue
Posted by Marcus Crafter <cr...@managesoft.com>.
Hi Peter,
Thanks for that information - didn't realize there were other issues in
that space as well that people knew about.
I'll take a look at the spice threadpool package as you suggested.
Are there also spice equivalents of cornerstone connection and socket
manager, that already use the thread manager you mention?
Cheers,
Marcus
Peter Donald wrote:
> Hi,
>
> Marcus Crafter wrote:
>
>>I think I've tracked down part of the cornerstone threadmanager
>>dispose() issue described in my previous email, but I'm not sure how to
>>handle it - any ideas appreciated :)
>
>
> I know it may not be much help but that code has many many many
> threading/synchronization issues and breaks in a whole range of
> environments. It was actually the motivation to create Spice-ThreadPool
> (http://spice.codehaus.org/threadpool/index.html) which has far more
> unit tests with much better coverage (~90% IIRC). I would highly
> recomend you dump the ThreadManager or if you can not due to legacy apps
> then make an adapter around the Spice-Threadpool code.
>
> Cheers,
>
> Peter Donald
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
> For additional commands, e-mail: dev-help@excalibur.apache.org
> Apache Excalibur Project -- URL: http://excalibur.apache.org/
>
--
.....
,,$$$$$$$$$, Marcus Crafter
;$' '$$$$: Computer Systems Engineer
$: $$$$: ManageSoft Corporation
$ o_)$$$: Frankfurt am Main, Germany
;$, _/\ &&:'
' /( &&&
\_&&&&'
&&&&.
&&&&&&&:
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/
Re: ThreadManager.dispose() issue
Posted by Peter Donald <pe...@realityforge.org>.
Hi,
Marcus Crafter wrote:
> I think I've tracked down part of the cornerstone threadmanager
> dispose() issue described in my previous email, but I'm not sure how to
> handle it - any ideas appreciated :)
I know it may not be much help but that code has many many many
threading/synchronization issues and breaks in a whole range of
environments. It was actually the motivation to create Spice-ThreadPool
(http://spice.codehaus.org/threadpool/index.html) which has far more
unit tests with much better coverage (~90% IIRC). I would highly
recomend you dump the ThreadManager or if you can not due to legacy apps
then make an adapter around the Spice-Threadpool code.
Cheers,
Peter Donald
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/