You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/04/18 22:56:28 UTC

DO NOT REPLY [Bug 39340] New: - Infinite loop in Evictor of GenericKeyedObjectPool

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39340>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39340

           Summary: Infinite loop in Evictor of GenericKeyedObjectPool
           Product: Commons
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Pool
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: stuart_brock@adp.com


When the maxIdle and maxTotal are equal, the Evictor thread rapidly loops to 
check for objects to evict.  This occurs regardless of what 
timeBetweenEvictionRunsMillis is set to.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39340] - [pool] Infinite loop in Evictor of GenericKeyedObjectPool

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39340>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39340


stuart_brock@adp.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|                            |WORKSFORME




------- Additional Comments From stuart_brock@adp.com  2006-04-19 23:36 -------
It appears that I may have made a mistake during my installation, as I am not 
able to recreate this problem today.  The jar is being used by an EJB in 
WebLogic, so it is very likely that something just wasn't right with my 
installation.  I have therefore marked the bug as resolved.

Addressing the aside.

You are correct Sandy, the QuoteVendorConnectionPool does extend the 
GenericKeyedObjectPool.  My thinking was that I could save a lot of 
development time by extending the GenericKeyedObjectPool, rather than 
implementing one of the interfaces or extending an abstract class.  Why 
reinvent the wheel, right?

Regarding the connection validation, you are again correct.  However, the 
connection protocol is optimistic and requires the use of a "heartbeat" 
message for validation.  As the error handling and reconnect logic is the same 
for both a heartbeat message and a quote request message, I won't actually 
save any time by sending a heartbeat message first.  I just send the quote 
request and in the case of failure attempt to reconnect.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39340] - [pool] Infinite loop in Evictor of GenericKeyedObjectPool

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39340>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39340


sandymac@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Infinite loop in Evictor of |[pool] Infinite loop in
                   |GenericKeyedObjectPool      |Evictor of
                   |                            |GenericKeyedObjectPool




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39340] - [pool] Infinite loop in Evictor of GenericKeyedObjectPool

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39340>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39340





------- Additional Comments From sandymac@apache.org  2006-04-19 17:33 -------
I still cannot reproduce the problem. Can you create a JUnit test that actually
produces the problem and attach that to this issue?

Off topic:
>From that code fragment you seem to be subclassing GenericKeyedOP but I cannot
tell for sure. If so, why do you think you need to subclass GKOP?

Also, why do you explicitly set testOnBorrow to false? In my mind it seems to me
better to test on borrow so only valid objects are ever borrowed from the pool.
In the time between returning an object to the pool and it being borrowed again
it could have become invalid by virtue of whatever connection your are pooling
breaking. By not testing on borrow you have to do the work to make sure its'
still a valid connection when the pool should be able to do that for you.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39340] - [pool] Infinite loop in Evictor of GenericKeyedObjectPool

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39340>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39340


sandymac@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO




------- Additional Comments From sandymac@apache.org  2006-04-19 03:25 -------
Could you provide some test code that triggers this infinite loop? Based on your
description I couldn't reproduce the problem.

As I read it, according to what you say the following should deadlock the pool
as eviction is synchronized and an infinite loop in the evictor wouldn't allow
other threads to borrow or return objects.

GenericKeyedObjectPool pool = ...;
pool.setMaxTotal(3);
pool.setMaxIdle(3);
pool.setTimeBetweenEvictionRunsMillis(100);
PoolUtils.prefill(pool, "a", 3);
Thread.sleep(150);
pool.borrowObject("a");

The last line would block forever waiting for the evictor to release it's
synchronization but in my test code all those lines execute and return promptly.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39340] - [pool] Infinite loop in Evictor of GenericKeyedObjectPool

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39340>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39340





------- Additional Comments From stuart_brock@adp.com  2006-04-19 16:54 -------
I probably didn't characterize this issue correctly.  Here is the 
configuration code I use:

    private static final int FIVE_MINUTES = 300000;
    private static final int TEN_MINUTES = 600000;
    private static final int ONE_HOUR = 3600000;

    public void configurePool(int maxConnections, int maxIdleConnections) {
        poolConfig = new GenericKeyedObjectPool.Config();
        poolConfig.maxActive = maxConnections;
        poolConfig.maxIdle = maxIdleConnections;
        poolConfig.maxTotal = maxConnections;
        poolConfig.maxWait = ONE_MINUTE;
        poolConfig.minEvictableIdleTimeMillis = ONE_HOUR;
        poolConfig.numTestsPerEvictionRun = maxConnections;
        poolConfig.testOnBorrow = false;
        poolConfig.testOnReturn = true;
        poolConfig.testWhileIdle = true;
        poolConfig.timeBetweenEvictionRunsMillis = TEN_MINUTES;
        poolConfig.whenExhaustedAction = 
GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK;
        super.setConfig(poolConfig);
        
        // Attempt to prepopulate the pool with idle realtime and
        // delayed connection.  If the operation fails, do nothing.
        //
        try {
            for (int i = 0; i < maxIdleConnections; i++) {
                addObject("REALTIME");
                addObject("DELAYED");
            }
        } catch (Exception e) {
            
            // Attempt to pre-populate failed.  Do nothing, as connections
            // will be created as they are borrowed.
        }
        startEvictor(FIVE_MINUTES);
    }

Both maxConnections and maxIdleConnections are set to 1.  I know it doesn't 
make any sense to create a pool of one object, but who am I to question 
managements decisions.

Anyway, when the evictor thread starts, it wakes up to check for idle threads 
so frequently that it blocks access to the pool.  I debugged the 
GenericKeyedObjectPool class and it appears to be setting the "wakeup" timer 
correctly.  I just didn't have time to take it any further.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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