aspose file tools*
The moose likes JBoss/WildFly and the fly likes DataSource Connections not closed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "DataSource Connections not closed " Watch "DataSource Connections not closed " New topic
Author

DataSource Connections not closed

lochan serma
Greenhorn

Joined: Apr 22, 2011
Posts: 23
Hi there,

I would like to know if there is some problem with our configuration. We are using JBoss 4.0.3SP1 and AJP port fronted by apache using mod_jk. Our service.xml file looks like this:



Currently, JMX console shows following stats for ManagedConnectionPool:



What I feel abnormal is the InUseConnectionCount. It's unlikely that an application at no load uses 2252 connections. Also i think the setting connectionTimeout=20000 for AJP port is not functional, even though the server.log shows connection timed out sequences. I wonder about the difference in value of ConnectionDestroyedCount and ConnectionCreatedCount which is greater than 3000 which clearly shows that connections are not being closed properly.
Can anyone give any idea about this?
I am hopeful.

Thank You
Lochan Serma
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

I'm confused. The title for your post mentions datasource connections. The service.xml file entries are for HTTP connections, not for database connections. In which case I am not exactly sure about the "stats for ManagedConnectionPool", were those for HTTP or datasource connections (it would help if you gave the full JMX mbean name.

I wonder about the difference in value of ConnectionDestroyedCount and ConnectionCreatedCount which is greater than 3000

ConnectionCreatedCount = ConnectionDestroyedCount + ConnectionCount

clearly shows that connections are not being closed properly.

If you are talking about HTTP connections, the only sane way to close them is to force your users to log out when they are done with accessing your app. The other thing you can do is lower the timeout threshold which would cause "stale" connections to be closed sooner. Of course this might also inconvenience users in one way or another, so you have to balance the user's desires with your desire to keep connections to a minimum.


JBoss In Action
lochan serma
Greenhorn

Joined: Apr 22, 2011
Posts: 23
Hi Peter,
Thank you so much for the reply and sorry for the confusion. Actually I was depicting the value connectionTimeout="20000" for the AJP port. The http port is not in use and has been commented.

Here is what the mssql-ds.xml file looks like.

<datasources>
<local-tx-datasource>
<jndi-name>DS</jndi-name>
<connection-url>jdbc:sqlserver://xxx.xxx.xxx.xxx:1433;database=abc</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<user-name>user</user-name>
<password>password</password>
<min-pool-size>500</min-pool-size>
<max-pool-size>4000</max-pool-size>
<blocking-timeout-millis>10000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>

<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>

We have set the max-pool-size to 4000. I was eager to know why our ConnectionCount is always rising and not resetting even when the application is idle. Since the timeout is set to 10 seconds i was thinking that the connection count should decrease as the connections are timed out. Please help me if i have misunderstood. Also the InUseConnectionCount has a value in thousands even when the application is idle. Do they increase until the AvailableConnectionCount reaches the MinSize? Shouldn't they reset after the connections are terminated?

Any help will be greatly appreciated.
Thank You
Lochan Serma
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

It should decrease unless you have a connection leak in your application (though the check-valid-connection-sql will use some connections fairly constantly). I would check how you close connections.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

The InUseConnectionCount indicates that your code (or actually, all code using that datasource - is that datasource used by messaging or any other services or apps?) currently has that many active connections to the database. The database might be able to tell you which queries were done on each connection - that might help you understand who still is holding on to the connection.
lochan serma
Greenhorn

Joined: Apr 22, 2011
Posts: 23
Hi Peter,

I used CachedConnectionManager to detect connection leaks and JBoss successfully closed open connections for me resulting very few InUseConnectionCount. However, it also closed the result sets in our application. Could you please help me set some fixed time interval after which the connections could be closed by Jboss? I could not figure out how JBoss determines which connections are totally inactive. Result Sets do need to exist for some time but i feel JBoss tries to close them immediately.

Any support on this issue would be greatly appreciated.

Thank You
Lochan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DataSource Connections not closed