You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Phil Steitz <ph...@gmail.com> on 2011/06/06 04:32:20 UTC

[pool] getNumActive returning -1

The AbandonedObjectPool test case that I just commented out in
[dbcp] trunk is failing because GOP getNumActive returns -1.  My
first thought was that this is a timing issue due to lack of
synchronization in invalidate and general non-protection of
_allObjects and _idleObjects; but I can't demonstrate this.  Looking
into it now...

Phil

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


Re: [pool] getNumActive returning -1

Posted by Phil Steitz <ph...@gmail.com>.
On 6/8/11 6:31 AM, Mark Thomas wrote:
> On 06/06/2011 08:34, Phil Steitz wrote:
>> On 6/5/11 7:32 PM, Phil Steitz wrote:
>>> The AbandonedObjectPool test case that I just commented out in
>>> [dbcp] trunk is failing because GOP getNumActive returns -1.  My
>>> first thought was that this is a timing issue due to lack of
>>> synchronization in invalidate and general non-protection of
>>> _allObjects and _idleObjects; but I can't demonstrate this.  Looking
>>> into it now...
>> I found the problem. The test object class was not threadsafe,
>> resulting in multiple equal instances generated by the factory. 
>> This results in returnObject replacing rather than duplicating
>> instances in _allObjects, which causes _allObjects to have fewer
>> instances than _idleObjects.  We need to think about this setup a
>> little, as it will break if equal instances are ever generated by
>> object factories and in circulation at the same time.  I think it is
>> a reasonable expectation that distinct instances generated by object
>> factories must not be equal; but this is a new requirement and it
>> needs to be documented and we might want to consider a guard for it.
> Good catch. I'm not sure I would have found that anywhere near that quickly.

Thanks!  Credit belongs to the [dbcp] AbandonedObjectPool test case,
though :)
> I'll look into putting a guard into pool for this.

Could also be that we should make _allObjects and _idleObjects have
the same semantics wrt equal instances, too.

Phil
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


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


Re: [pool] getNumActive returning -1

Posted by Mark Thomas <ma...@apache.org>.
On 06/06/2011 08:34, Phil Steitz wrote:
> On 6/5/11 7:32 PM, Phil Steitz wrote:
>> The AbandonedObjectPool test case that I just commented out in
>> [dbcp] trunk is failing because GOP getNumActive returns -1.  My
>> first thought was that this is a timing issue due to lack of
>> synchronization in invalidate and general non-protection of
>> _allObjects and _idleObjects; but I can't demonstrate this.  Looking
>> into it now...
> 
> I found the problem. The test object class was not threadsafe,
> resulting in multiple equal instances generated by the factory. 
> This results in returnObject replacing rather than duplicating
> instances in _allObjects, which causes _allObjects to have fewer
> instances than _idleObjects.  We need to think about this setup a
> little, as it will break if equal instances are ever generated by
> object factories and in circulation at the same time.  I think it is
> a reasonable expectation that distinct instances generated by object
> factories must not be equal; but this is a new requirement and it
> needs to be documented and we might want to consider a guard for it.

Good catch. I'm not sure I would have found that anywhere near that quickly.

I'll look into putting a guard into pool for this.

Mark

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


Re: [pool] getNumActive returning -1

Posted by Phil Steitz <ph...@gmail.com>.
On 6/5/11 7:32 PM, Phil Steitz wrote:
> The AbandonedObjectPool test case that I just commented out in
> [dbcp] trunk is failing because GOP getNumActive returns -1.  My
> first thought was that this is a timing issue due to lack of
> synchronization in invalidate and general non-protection of
> _allObjects and _idleObjects; but I can't demonstrate this.  Looking
> into it now...

I found the problem. The test object class was not threadsafe,
resulting in multiple equal instances generated by the factory. 
This results in returnObject replacing rather than duplicating
instances in _allObjects, which causes _allObjects to have fewer
instances than _idleObjects.  We need to think about this setup a
little, as it will break if equal instances are ever generated by
object factories and in circulation at the same time.  I think it is
a reasonable expectation that distinct instances generated by object
factories must not be equal; but this is a new requirement and it
needs to be documented and we might want to consider a guard for it.

Phil
> Phil


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