More DB connections than what is in maxActive?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

More DB connections than what is in maxActive?

Antoine Roux
Hi,
My app is running on a Tomcat against a MySQL server. We had recently a "Too many connections" error on MySQL. It was caused by the application using nearly 500 connections to the MySQL server, which consequently hit the max number of connections configured.
I use the connection pool from Tomcat and I set the maxActive connections to 100. So theorretically, the application should never open more than 100 connections. In our case we were close to 500, way above the limit.

Do you know why our application crossed the limit? Is it a bad configuration, or a known issue?

Here is the data source config in Tomcat's server.xml:

<Resource name="jdbc/nvds" auth="Application" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="REMOVED"
              password="REMOVED"
              driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://ip.address.1,ip.address.2:3306/dbName?autoReconnect=true&amp;failOverReadOnly=false"
              removeAbandoned="true"
              removeAbandonedTimeout="60"
              validationQuery="SELECT 1;"/>


Thanks.


Antoine
Reply | Threaded
Open this post in threaded view
|

Re: More DB connections than what is in maxActive?

Antoine Roux
Hi,
No one never had this issue?

Thanks.


Antoine


On Fri, Jan 20, 2012 at 6:53 PM, Antoine Roux <[hidden email]> wrote:
Hi,
My app is running on a Tomcat against a MySQL server. We had recently a "Too many connections" error on MySQL. It was caused by the application using nearly 500 connections to the MySQL server, which consequently hit the max number of connections configured.
I use the connection pool from Tomcat and I set the maxActive connections to 100. So theorretically, the application should never open more than 100 connections. In our case we were close to 500, way above the limit.

Do you know why our application crossed the limit? Is it a bad configuration, or a known issue?

Here is the data source config in Tomcat's server.xml:

<Resource name="jdbc/nvds" auth="Application" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="REMOVED"
              password="REMOVED"
              driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://ip.address.1,ip.address.2:3306/dbName?autoReconnect=true&amp;failOverReadOnly=false"
              removeAbandoned="true"
              removeAbandonedTimeout="60"
              validationQuery="SELECT 1;"/>


Thanks.


Antoine

Reply | Threaded
Open this post in threaded view
|

Re: More DB connections than what is in maxActive?

pledbrook
In reply to this post by Antoine Roux
> Do you know why our application crossed the limit? Is it a bad
> configuration, or a known issue?

Which version of Tomcat are you using?

Some suggestions from a colleague:

1. Use JMX to monitor the data source in Tomcat to see whether any
connections are being left open.
2. Is the application the only thing hitting that particular database?
3. Check whether the DB connection is being closed (bad code or server
restarts may be leaving it open)

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: More DB connections than what is in maxActive?

Antoine Roux
Hi Peter,
Thanks for the info.

I am using Tomcat 6.

I will try the JMX stuff, although it happens at customer site only and I do not have access, so it will be difficult. But that would be ideal.

The application is the only one on this server hitting the database, and the SHOW PROCESSLIST in MySQL shows clearly that the issue is coming from this server.

Restarting the server closed the existing connections. Regarding the code, I am only using Grails/Hibernate.

If a thread opened a transaction and froze inside a transaction, I guess the connection would never be released? But what would happen in that case? I guess, when reaching the limit, the next thread needing a connection would never get one, or get an exception?


Antoine



On Mon, Jan 23, 2012 at 2:12 PM, Peter Ledbrook <[hidden email]> wrote:
> Do you know why our application crossed the limit? Is it a bad
> configuration, or a known issue?

Which version of Tomcat are you using?

Some suggestions from a colleague:

1. Use JMX to monitor the data source in Tomcat to see whether any
connections are being left open.
2. Is the application the only thing hitting that particular database?
3. Check whether the DB connection is being closed (bad code or server
restarts may be leaving it open)

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email