Discussion:
How to forcibly close abandoned database connections?
David Uctaa
2007-01-08 15:48:27 UTC
Permalink
Tomcat provides the removeAbandoned and removeAbandonedTimeout
parameters when setting up data sources in server.xml. But according
to the documentation I've read, abandoned connections only get closed
and recycled when available connections run low and new connections
are requested.

Is there a way for me to forcibly close/release abandoned connections
on the server from a privileged application running on the same
server?

BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
the pooling.

Thanks,
David

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
David Uctaa
2007-01-10 13:32:41 UTC
Permalink
Perhaps I was unclear what it is I'm trying to do. I have a
connection pool set up under Tomcat 5.5, connecting to DB2 on an
iSeries box using Tomcat's DBCP. It is set up for 30 connections. I
am using Lambda Probe (a great open source Tomcat monitoring app) to
monitor the datasources. It is showing, let's say, that there are a
max of 30 connections allowed, that 11 have been "established", and 9
are "busy". I know that these 9 are due to a connection pool leak bug
that was corrected (but not yet deployed), so even though the
application has gone idle and no one is using it, the connections
remain "busy" indefinitely. I have enabled removeAbandoned in my
server.xml, but according to the Tomcat docs, abandoned connections
are only recycled if there is a need for them, due to the number of
available datasources getting low. The number of available
datasources are not yet low, so these orphaned connections are still
being reported as "busy". I'm a little bit anal with regard to
keeping things kinda clean on the server, so I would like to have
these abandoned connections no longer reported as "busy" once they are
orphaned. Is there a way to find and recycle abandoned connections
forcibly?

Thanks,
David
Post by David Uctaa
Tomcat provides the removeAbandoned and removeAbandonedTimeout
parameters when setting up data sources in server.xml. But according
to the documentation I've read, abandoned connections only get closed
and recycled when available connections run low and new connections
are requested.
Is there a way for me to forcibly close/release abandoned connections
on the server from a privileged application running on the same
server?
BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
the pooling.
Thanks,
David
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
EDMOND KEMOKAI
2007-01-10 14:04:11 UTC
Permalink
It is possible that whatever procedure is responsible for checking for
abandoned connections only does so when there is actual need for a
connection, similar to how a garbage collector works to reclaim memory. If
there is no seeming stress on the connection resources then it would make
sense not to jump the gun to look for and recycle abandoned connections. Of
course I don't know if that is what is happening, but I suspect it might be.
Post by David Uctaa
Perhaps I was unclear what it is I'm trying to do. I have a
connection pool set up under Tomcat 5.5, connecting to DB2 on an
iSeries box using Tomcat's DBCP. It is set up for 30 connections. I
am using Lambda Probe (a great open source Tomcat monitoring app) to
monitor the datasources. It is showing, let's say, that there are a
max of 30 connections allowed, that 11 have been "established", and 9
are "busy". I know that these 9 are due to a connection pool leak bug
that was corrected (but not yet deployed), so even though the
application has gone idle and no one is using it, the connections
remain "busy" indefinitely. I have enabled removeAbandoned in my
server.xml, but according to the Tomcat docs, abandoned connections
are only recycled if there is a need for them, due to the number of
available datasources getting low. The number of available
datasources are not yet low, so these orphaned connections are still
being reported as "busy". I'm a little bit anal with regard to
keeping things kinda clean on the server, so I would like to have
these abandoned connections no longer reported as "busy" once they are
orphaned. Is there a way to find and recycle abandoned connections
forcibly?
Thanks,
David
Post by David Uctaa
Tomcat provides the removeAbandoned and removeAbandonedTimeout
parameters when setting up data sources in server.xml. But according
to the documentation I've read, abandoned connections only get closed
and recycled when available connections run low and new connections
are requested.
Is there a way for me to forcibly close/release abandoned connections
on the server from a privileged application running on the same
server?
BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
the pooling.
Thanks,
David
---------------------------------------------------------------------
--
"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)
David Uctaa
2007-01-10 14:18:58 UTC
Permalink
I agree that is probably what is happening, since the application has
gone idle. However, with garbage collection, while it will only
reclaim memory when necessary, there is a way to force garbage
collection. I am looking for a similar process with abandoned
database connections.
Post by EDMOND KEMOKAI
It is possible that whatever procedure is responsible for checking for
abandoned connections only does so when there is actual need for a
connection, similar to how a garbage collector works to reclaim memory. If
there is no seeming stress on the connection resources then it would make
sense not to jump the gun to look for and recycle abandoned connections. Of
course I don't know if that is what is happening, but I suspect it might be.
Post by David Uctaa
Perhaps I was unclear what it is I'm trying to do. I have a
connection pool set up under Tomcat 5.5, connecting to DB2 on an
iSeries box using Tomcat's DBCP. It is set up for 30 connections. I
am using Lambda Probe (a great open source Tomcat monitoring app) to
monitor the datasources. It is showing, let's say, that there are a
max of 30 connections allowed, that 11 have been "established", and 9
are "busy". I know that these 9 are due to a connection pool leak bug
that was corrected (but not yet deployed), so even though the
application has gone idle and no one is using it, the connections
remain "busy" indefinitely. I have enabled removeAbandoned in my
server.xml, but according to the Tomcat docs, abandoned connections
are only recycled if there is a need for them, due to the number of
available datasources getting low. The number of available
datasources are not yet low, so these orphaned connections are still
being reported as "busy". I'm a little bit anal with regard to
keeping things kinda clean on the server, so I would like to have
these abandoned connections no longer reported as "busy" once they are
orphaned. Is there a way to find and recycle abandoned connections
forcibly?
Thanks,
David
Post by David Uctaa
Tomcat provides the removeAbandoned and removeAbandonedTimeout
parameters when setting up data sources in server.xml. But according
to the documentation I've read, abandoned connections only get closed
and recycled when available connections run low and new connections
are requested.
Is there a way for me to forcibly close/release abandoned connections
on the server from a privileged application running on the same
server?
BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
the pooling.
Thanks,
David
---------------------------------------------------------------------
--
"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Varley, Roger
2007-01-10 14:37:29 UTC
Permalink
Post by David Uctaa
I agree that is probably what is happening, since the application has
gone idle. However, with garbage collection, while it will only
reclaim memory when necessary, there is a way to force garbage
collection. I am looking for a similar process with abandoned
database connections.
If the connections will only re-cycle with increased demand, could you not create that demand with an "admin" type program that requests, opens & then closes X connections?

Regards
Roger

_______________________________________________________

This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted.
_______________________________________________________

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
David Uctaa
2007-01-10 14:46:31 UTC
Permalink
Possible. I'll give it a try...
Post by Varley, Roger
Post by David Uctaa
I agree that is probably what is happening, since the application has
gone idle. However, with garbage collection, while it will only
reclaim memory when necessary, there is a way to force garbage
collection. I am looking for a similar process with abandoned
database connections.
If the connections will only re-cycle with increased demand, could you not create that demand with an "admin" type program that requests, opens & then closes X connections?
Regards
Roger
_______________________________________________________
This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted.
_______________________________________________________
---------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
David Uctaa
2007-01-11 20:28:12 UTC
Permalink
Created a little admin app to do just that, and it worked perfectly.
All the connections being shown as "busy" cleared right out, and only
the minimum number of idle / available connections remained.

Thanks much.
Post by Varley, Roger
Post by David Uctaa
I agree that is probably what is happening, since the application has
gone idle. However, with garbage collection, while it will only
reclaim memory when necessary, there is a way to force garbage
collection. I am looking for a similar process with abandoned
database connections.
If the connections will only re-cycle with increased demand, could you not create that demand with an "admin" type program that requests, opens & then closes X connections?
Regards
Roger
_______________________________________________________
This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted.
_______________________________________________________
---------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Greg Foulks
2007-01-10 15:03:11 UTC
Permalink
David,
Any chance you could share with me your connection pool configuration? I've
been struggling with trying to setup my own connection to our DB2 using the
jt400 jar and have not been able to find any documentation for doing this
with a DB2 connection.

Thanks,
Greg
Post by David Uctaa
Perhaps I was unclear what it is I'm trying to do. I have a
connection pool set up under Tomcat 5.5, connecting to DB2 on an
iSeries box using Tomcat's DBCP. It is set up for 30 connections. I
am using Lambda Probe (a great open source Tomcat monitoring app) to
monitor the datasources. It is showing, let's say, that there are a
max of 30 connections allowed, that 11 have been "established", and 9
are "busy". I know that these 9 are due to a connection pool leak bug
that was corrected (but not yet deployed), so even though the
application has gone idle and no one is using it, the connections
remain "busy" indefinitely. I have enabled removeAbandoned in my
server.xml, but according to the Tomcat docs, abandoned connections
are only recycled if there is a need for them, due to the number of
available datasources getting low. The number of available
datasources are not yet low, so these orphaned connections are still
being reported as "busy". I'm a little bit anal with regard to
keeping things kinda clean on the server, so I would like to have
these abandoned connections no longer reported as "busy" once they are
orphaned. Is there a way to find and recycle abandoned connections
forcibly?
Thanks,
David
Post by David Uctaa
Tomcat provides the removeAbandoned and removeAbandonedTimeout
parameters when setting up data sources in server.xml. But according
to the documentation I've read, abandoned connections only get closed
and recycled when available connections run low and new connections
are requested.
Is there a way for me to forcibly close/release abandoned connections
on the server from a privileged application running on the same
server?
BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
the pooling.
Thanks,
David
---------------------------------------------------------------------
David Uctaa
2007-01-10 16:10:05 UTC
Permalink
In server.xml, within GlobalNamingResources, include something like this:

<Resource
auth="Container"
driverClassName="com.ibm.as400.access.AS400JDBCDriver"
maxActive="30"
maxIdle="2"
maxWait="5000"
name="jdbc/something"
password="password"
type="javax.sql.DataSource"
url="jdbc:as400://abc.def.com"
username="username"
removeAbandoned="true"
removeAbandonedTimeout="120"
logAbandoned="true"/>

Within the context.xml in your application's META-INF folder, include
this underneath the <Context> element:

<ResourceLink
global="jdbc/something"
name="jdbc/something"
type="javax.sql.DataSource" />

Within your appilcation code, include something like this:

InitialContext initCtx = new InitialContext();
Context ctx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("jdbc/something");
Connection con = ds.getConnection();

Make sure jt400.jar resides in your tomcat's common/lib folder

Hope this helps.
Post by Greg Foulks
David,
Any chance you could share with me your connection pool configuration? I've
been struggling with trying to setup my own connection to our DB2 using the
jt400 jar and have not been able to find any documentation for doing this
with a DB2 connection.
Thanks,
Greg
Post by David Uctaa
Perhaps I was unclear what it is I'm trying to do. I have a
connection pool set up under Tomcat 5.5, connecting to DB2 on an
iSeries box using Tomcat's DBCP. It is set up for 30 connections. I
am using Lambda Probe (a great open source Tomcat monitoring app) to
monitor the datasources. It is showing, let's say, that there are a
max of 30 connections allowed, that 11 have been "established", and 9
are "busy". I know that these 9 are due to a connection pool leak bug
that was corrected (but not yet deployed), so even though the
application has gone idle and no one is using it, the connections
remain "busy" indefinitely. I have enabled removeAbandoned in my
server.xml, but according to the Tomcat docs, abandoned connections
are only recycled if there is a need for them, due to the number of
available datasources getting low. The number of available
datasources are not yet low, so these orphaned connections are still
being reported as "busy". I'm a little bit anal with regard to
keeping things kinda clean on the server, so I would like to have
these abandoned connections no longer reported as "busy" once they are
orphaned. Is there a way to find and recycle abandoned connections
forcibly?
Thanks,
David
Post by David Uctaa
Tomcat provides the removeAbandoned and removeAbandonedTimeout
parameters when setting up data sources in server.xml. But according
to the documentation I've read, abandoned connections only get closed
and recycled when available connections run low and new connections
are requested.
Is there a way for me to forcibly close/release abandoned connections
on the server from a privileged application running on the same
server?
BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
the pooling.
Thanks,
David
---------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Loading...