You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Wm.A.Stafford" <st...@marine.rutgers.edu> on 2007/10/12 21:12:47 UTC

DBCP - What is this thread dump telling me?

Our Tomcat instance has been hanging add odd  intervals. 
We see many, many identical thread dumps like this:

http-8082-Processor84" daemon prio=10 tid=0x0887c000 nid=0x5663 in 
Object.wait() [0x6c1ad000..0x6c1ae030]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x75132118> (a 
org.apache.commons.dbcp.AbandonedObjectPool)
    at java.lang.Object.wait(Object.java:485)
    at 
org.apache.commons.pool.impl.GenericObjectPool.borrowObject(Unknown Source)
    - locked <0x75132118> (a org.apache.commons.dbcp.AbandonedObjectPool)
    at 
org.apache.commons.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:117)
    - locked <0x75132118> (a org.apache.commons.dbcp.AbandonedObjectPool)
    at 
org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:110)
    at 
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312)
    at 
dbAccess.FailSafeConnectionPool.getConnection(FailSafeConnectionPool.java:162)
    at servlets.ControllerServlet.doGet(ObisControllerServlet.java:93)

There is clearly something pathological going on but I'm not sure what.  
It looks to me like this and all the other threads are waiting on 
org.apache.commons.dbcp.AbandonedObjectPool which is locked by another 
thread.  But I can not deduce much more.

We are using dbcp-1.0.  The code handles connections rather strangely 
but it seems to be closing them correctly.  There is one static 
Connection object and a call to a local getConnection() calls close() on 
this static connection then replaces it with a connection returned by a 
call to BasicDataSource.getConnection(). 

There is one exception handler that calls close() on the BasicDataSource 
and then creates a new one. I thought this might be the problem, that 
somehow the connections associated with the previous BasicDataSource 
were still being held but I can't see a scenario that would do this.

We are also using a BasicDataSource in our Spring enabled DAOs but there 
is no common code sheared by these and the legacy code that is being 
fingered by the thread dump.

Any help or advice will be greatly appreciated,
-=beeky



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


Re: DBCP - Where does logAbandoned log?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
DBCP doesn't remove abandoned connections until you reach maxActive, so 
you need to set your maxactive to something low that you can hit pretty 
easily

Filip

Wm.A.Stafford wrote:
> Filip,
>    Thanks for the reply.  Here is my code:
>               BasicDataSource ds = new BasicDataSource();
>          ds.setDriverClassName(bundle.getString("Driver"));
>          ds.setUsername(bundle.getString("UserStr"));
>          ds.setPassword(bundle.getString("PwdStr"));
>          ds.setUrl( bundle.getString("URLStr"));
>          ds.setRemoveAbandoned(true);
>          ds.setRemoveAbandonedTimeout(30);
>          ds.setLogAbandoned(true);
>
>    When I start the app I do see a message on sysout indicating the 
> abandoned settings:
> AbandonedObjectPool is used 
> (org.apache.commons.dbcp.AbandonedObjectPool@987a33)
>   LogAbandoned: true
>   RemoveAbandoned: true
>   RemoveAbandonedTimeout: 30
> Date set:Sat Oct 20 00:00:00 EDT 2007
>
>    But, as I said earlier, I don't see any other logging when the app 
> is running or subsequently shut down.
>
>    -=bill
>
>
> Filip Hanik - Dev Lists wrote:
>> you must also set
>>
>> *removeAbandoned*="true"
>>
>> Filip
>>
>> Wm.A.Stafford wrote:
>>> I am trying to track down a connection leak in a Tomcat app that 
>>> uses dbcp.  I was hoping that logging abandoned connections would 
>>> give some clue as to where the leak is occurring.  I set 
>>> logAbandoned to be true and removeAbandonedTimeout to 30. I  added 
>>> Connection c = getConnection() with no c.close() to a servlet.  I 
>>> was expecting to see some sort of logging whenever this servlet 
>>> handled a request but I have seen nothing in any of the usual logs.  
>>> Where do the stack traces get logged?  Is my test case sufficient to 
>>> cause logging?  I am using dbcp1.2.2.
>>>
>>> Thanks,
>>> -=bill
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
>


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


Re: DBCP - Where does logAbandoned log?

Posted by "Wm.A.Stafford" <st...@marine.rutgers.edu>.
Filip,
    Thanks for the reply.  Here is my code:
      
          BasicDataSource ds = new BasicDataSource();
          ds.setDriverClassName(bundle.getString("Driver"));
          ds.setUsername(bundle.getString("UserStr"));
          ds.setPassword(bundle.getString("PwdStr"));
          ds.setUrl( bundle.getString("URLStr"));
          ds.setRemoveAbandoned(true);
          ds.setRemoveAbandonedTimeout(30);
          ds.setLogAbandoned(true);

    When I start the app I do see a message on sysout indicating the 
abandoned settings:
AbandonedObjectPool is used 
(org.apache.commons.dbcp.AbandonedObjectPool@987a33)
   LogAbandoned: true
   RemoveAbandoned: true
   RemoveAbandonedTimeout: 30
Date set:Sat Oct 20 00:00:00 EDT 2007

    But, as I said earlier, I don't see any other logging when the app 
is running or subsequently shut down.

    -=bill


Filip Hanik - Dev Lists wrote:
> you must also set
>
> *removeAbandoned*="true"
>
> Filip
>
> Wm.A.Stafford wrote:
>> I am trying to track down a connection leak in a Tomcat app that uses 
>> dbcp.  I was hoping that logging abandoned connections would give 
>> some clue as to where the leak is occurring.  I set logAbandoned to 
>> be true and removeAbandonedTimeout to 30. I  added Connection c = 
>> getConnection() with no c.close() to a servlet.  I was expecting to 
>> see some sort of logging whenever this servlet handled a request but 
>> I have seen nothing in any of the usual logs.  Where do the stack 
>> traces get logged?  Is my test case sufficient to cause logging?  I 
>> am using dbcp1.2.2.
>>
>> Thanks,
>> -=bill
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>


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


Re: DBCP - Where does logAbandoned log?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
you must also set

*removeAbandoned*="true"

Filip

Wm.A.Stafford wrote:
> I am trying to track down a connection leak in a Tomcat app that uses 
> dbcp.  I was hoping that logging abandoned connections would give some 
> clue as to where the leak is occurring.  I set logAbandoned to be true 
> and removeAbandonedTimeout to 30. I  added Connection c = 
> getConnection() with no c.close() to a servlet.  I was expecting to 
> see some sort of logging whenever this servlet handled a request but I 
> have seen nothing in any of the usual logs.  Where do the stack traces 
> get logged?  Is my test case sufficient to cause logging?  I am using 
> dbcp1.2.2.
>
> Thanks,
> -=bill
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
>


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


DBCP - Where does logAbandoned log?

Posted by "Wm.A.Stafford" <st...@marine.rutgers.edu>.
I am trying to track down a connection leak in a Tomcat app that uses 
dbcp.  I was hoping that logging abandoned connections would give some 
clue as to where the leak is occurring.  I set logAbandoned to be true 
and removeAbandonedTimeout to 30. I  added Connection c = 
getConnection() with no c.close() to a servlet.  I was expecting to see 
some sort of logging whenever this servlet handled a request but I have 
seen nothing in any of the usual logs.  Where do the stack traces get 
logged?  Is my test case sufficient to cause logging?  I am using dbcp1.2.2.

Thanks,
-=bill

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


Re: DBCP - What is this thread dump telling me?

Posted by "Wm.A.Stafford" <st...@marine.rutgers.edu>.
Filip,
    Thanks for the reply.  I have my doubts about unclosed connections 
as the cause because this application ran for a year using an Oracle 
DataSource class with no problems.  We moved to DPCP in order to support 
non-oracle DBs and that is when the problem started.

    If the problem was simply running out of connections would there be 
all these threads in wait state?   getConnecton() throws an SQLException 
if it can't get a connection.  Wouldn't that case apply if there were no 
connections available?  Based on the thread dump the problem seems to be 
related to a locked object that the getConnection logic is trying to access.

Any help or advice will be greatly appreciated,
-=beeky

Filip Hanik - Dev Lists wrote:
> looks like you are running out of connections, and on the contrary to 
> what you say, you are not closing them correctly :)
> what if you replace the static connection object with a new one before 
> you called close on the old one
>
> Filip
>
> Wm.A.Stafford wrote:
>> Our Tomcat instance has been hanging add odd  intervals. We see many, 
>> many identical thread dumps like this:
>>
>> http-8082-Processor84" daemon prio=10 tid=0x0887c000 nid=0x5663 in 
>> Object.wait() [0x6c1ad000..0x6c1ae030]
>>   java.lang.Thread.State: WAITING (on object monitor)
>>    at java.lang.Object.wait(Native Method)
>>    - waiting on <0x75132118> (a 
>> org.apache.commons.dbcp.AbandonedObjectPool)
>>    at java.lang.Object.wait(Object.java:485)
>>    at 
>> org.apache.commons.pool.impl.GenericObjectPool.borrowObject(Unknown 
>> Source)
>>    - locked <0x75132118> (a org.apache.commons.dbcp.AbandonedObjectPool)
>>    at 
>> org.apache.commons.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:117) 
>>
>>    - locked <0x75132118> (a org.apache.commons.dbcp.AbandonedObjectPool)
>>    at 
>> org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:110) 
>>
>>    at 
>> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312) 
>>
>>    at 
>> dbAccess.FailSafeConnectionPool.getConnection(FailSafeConnectionPool.java:162) 
>>
>>    at servlets.ControllerServlet.doGet(ObisControllerServlet.java:93)
>>
>> There is clearly something pathological going on but I'm not sure 
>> what.  It looks to me like this and all the other threads are waiting 
>> on org.apache.commons.dbcp.AbandonedObjectPool which is locked by 
>> another thread.  But I can not deduce much more.
>>
>> We are using dbcp-1.0.  The code handles connections rather strangely 
>> but it seems to be closing them correctly.  There is one static 
>> Connection object and a call to a local getConnection() calls close() 
>> on this static connection then replaces it with a connection returned 
>> by a call to BasicDataSource.getConnection().
>> There is one exception handler that calls close() on the 
>> BasicDataSource and then creates a new one. I thought this might be 
>> the problem, that somehow the connections associated with the 
>> previous BasicDataSource were still being held but I can't see a 
>> scenario that would do this.
>>
>> We are also using a BasicDataSource in our Spring enabled DAOs but 
>> there is no common code sheared by these and the legacy code that is 
>> being fingered by the thread dump.
>>
>> Any help or advice will be greatly appreciated,
>> -=beeky
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

-- 

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


Re: DBCP - What is this thread dump telling me?

Posted by Guoxue Zhang <zg...@yahoo.com>.
Hello 
   
  I want to learn UML. Who know where I can download a video totuorl? Thank you.
   
  Frank
   
   

       
---------------------------------
Pinpoint customers who are looking for what you sell. 

Re: DBCP - What is this thread dump telling me?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
looks like you are running out of connections, and on the contrary to 
what you say, you are not closing them correctly :)
what if you replace the static connection object with a new one before 
you called close on the old one

Filip

Wm.A.Stafford wrote:
> Our Tomcat instance has been hanging add odd  intervals. We see many, 
> many identical thread dumps like this:
>
> http-8082-Processor84" daemon prio=10 tid=0x0887c000 nid=0x5663 in 
> Object.wait() [0x6c1ad000..0x6c1ae030]
>   java.lang.Thread.State: WAITING (on object monitor)
>    at java.lang.Object.wait(Native Method)
>    - waiting on <0x75132118> (a 
> org.apache.commons.dbcp.AbandonedObjectPool)
>    at java.lang.Object.wait(Object.java:485)
>    at 
> org.apache.commons.pool.impl.GenericObjectPool.borrowObject(Unknown 
> Source)
>    - locked <0x75132118> (a org.apache.commons.dbcp.AbandonedObjectPool)
>    at 
> org.apache.commons.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:117) 
>
>    - locked <0x75132118> (a org.apache.commons.dbcp.AbandonedObjectPool)
>    at 
> org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:110) 
>
>    at 
> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312) 
>
>    at 
> dbAccess.FailSafeConnectionPool.getConnection(FailSafeConnectionPool.java:162) 
>
>    at servlets.ControllerServlet.doGet(ObisControllerServlet.java:93)
>
> There is clearly something pathological going on but I'm not sure 
> what.  It looks to me like this and all the other threads are waiting 
> on org.apache.commons.dbcp.AbandonedObjectPool which is locked by 
> another thread.  But I can not deduce much more.
>
> We are using dbcp-1.0.  The code handles connections rather strangely 
> but it seems to be closing them correctly.  There is one static 
> Connection object and a call to a local getConnection() calls close() 
> on this static connection then replaces it with a connection returned 
> by a call to BasicDataSource.getConnection().
> There is one exception handler that calls close() on the 
> BasicDataSource and then creates a new one. I thought this might be 
> the problem, that somehow the connections associated with the previous 
> BasicDataSource were still being held but I can't see a scenario that 
> would do this.
>
> We are also using a BasicDataSource in our Spring enabled DAOs but 
> there is no common code sheared by these and the legacy code that is 
> being fingered by the thread dump.
>
> Any help or advice will be greatly appreciated,
> -=beeky
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
>


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