You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Matthias Pekny <ma...@gmx.at> on 2003/10/24 14:47:39 UTC

[DBCP] abandoned connections problem

I'm using dbcp in combination with tomcat 4.1.27.

According to the tomcat docs there is the possibility to let dbcp handle 
abandoned connections. As I understand it this includes connections that 
are opened by an web application but are never closed.

To verify this, I've created a jsp test page, that does exactly that. 
Open several db connections, but doesn't close it. (The connections are 
not used to access the db, they just get opened)

In the server.xml file there are entries that resemble those from the 
docs example config in the context of the application:

<!-- handling of abandoned connections -->
<parameter>
     <name>removeAbandoned</name>
     <value>true</value>
</parameter>
<!-- timeout in seconds -->
<parameter>
     <name>removeAbandonedTimeout</name>
     <value>30</value>
</parameter>
<parameter>
     <name>logAbandoned</name>
     <value>true</value>
</parameter>


However the connections stay open and won't get closed.

It is, of course, not important to get the test page running, but the 
behaviour is the same for an real application and this causes major 
problems.

Yes, I know that it is important to close the connections and not let 
tomcat handle this.

Any help with this is truly appreciated.


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


Re: [DBCP] abandoned connections problem

Posted by Dirk Verbeeck <di...@pandora.be>.
The formula to trigger the abandoned mechanism is hardcoded.
Making it dynamic isn't worth the effort IMHO.
If you have that many abandoned connection problems that you can better invest 
in solving them and not spending time to tune the workaround.

But if you have suggestions to optimize the default values then we can always 
take a look at it. A multi threaded testcase would also be nice.

--- Dirk

Matthias Pekny wrote:

> Dirk Verbeeck wrote:
> 
>> I have my own jsp page and it works for me :-)
>> Try it yourself:
>>    http://cvs.apache.org/viewcvs/jakarta-commons/dbcp/doc/
>>
> [...]
> 
>> <parameter><name>removeAbandonedTimeout</name><value>0</value></parameter> 
>>
> 
> 
> It seems that setting the timeout to 0 does the trick. Thanks for the hint.
> [...]
> 
>>
>> The conditions to activate the abandoned mechanism are:
>>    (getNumIdle() <  2) and (getNumActive() >  getMaxActive() - 3)
> 
> 
> Is there a way (I've missed in the docs up to now) to change this 
> behaviour? Except from changing the sources ;)




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


Re: [DBCP] abandoned connections problem

Posted by Matthias Pekny <ma...@gmx.at>.
Dirk Verbeeck wrote:
> I have my own jsp page and it works for me :-)
> Try it yourself:
>    http://cvs.apache.org/viewcvs/jakarta-commons/dbcp/doc/
> 
[...]
> <parameter><name>removeAbandonedTimeout</name><value>0</value></parameter>

It seems that setting the timeout to 0 does the trick. Thanks for the hint.
[...]
> 
> The conditions to activate the abandoned mechanism are:
>    (getNumIdle() <  2) and (getNumActive() >  getMaxActive() - 3)

Is there a way (I've missed in the docs up to now) to change this 
behaviour? Except from changing the sources ;)


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


Re: [DBCP] abandoned connections problem

Posted by Dirk Verbeeck <di...@pandora.be>.
I have my own jsp page and it works for me :-)
Try it yourself:
    http://cvs.apache.org/viewcvs/jakarta-commons/dbcp/doc/

Be sure to use the following configuration:
     <Resource name="jdbc/abandoned" auth="Container" type="javax.sql.DataSource"/>
     <ResourceParams name="jdbc/abandoned">
       <parameter><name>username</name><value>sa</value></parameter>
       <parameter><name>password</name><value></value></parameter>
 
<parameter><name>driverClassName</name><value>org.hsqldb.jdbcDriver</value></parameter>
       <parameter><name>url</name><value>jdbc:hsqldb:database</value></parameter>

       <parameter><name>removeAbandoned</name><value>true</value></parameter>
       <parameter><name>removeAbandonedTimeout</name><value>0</value></parameter>
       <parameter><name>logAbandoned</name><value>true</value></parameter>

       <parameter><name>maxActive</name><value>1</value></parameter>
     </ResourceParams>


The conditions to activate the abandoned mechanism are:
    (getNumIdle() <  2) and (getNumActive() >  getMaxActive() - 3)


-- Dirk

Matthias Pekny wrote:

> I'm using dbcp in combination with tomcat 4.1.27.
> 
> According to the tomcat docs there is the possibility to let dbcp handle 
> abandoned connections. As I understand it this includes connections that 
> are opened by an web application but are never closed.
> 
> To verify this, I've created a jsp test page, that does exactly that. 
> Open several db connections, but doesn't close it. (The connections are 
> not used to access the db, they just get opened)
> 
> In the server.xml file there are entries that resemble those from the 
> docs example config in the context of the application:
> 
> <!-- handling of abandoned connections -->
> <parameter>
>     <name>removeAbandoned</name>
>     <value>true</value>
> </parameter>
> <!-- timeout in seconds -->
> <parameter>
>     <name>removeAbandonedTimeout</name>
>     <value>30</value>
> </parameter>
> <parameter>
>     <name>logAbandoned</name>
>     <value>true</value>
> </parameter>
> 
> 
> However the connections stay open and won't get closed.
> 
> It is, of course, not important to get the test page running, but the 
> behaviour is the same for an real application and this causes major 
> problems.
> 
> Yes, I know that it is important to close the connections and not let 
> tomcat handle this.
> 
> Any help with this is truly appreciated.




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