Profile Image
Abhilasha

Why mysql DB connections count increasing and reached nearer to max limit

I am using connection pooling in my java web application. DB connection count gradullay increasing.at time of issue show processlist command at mysql gives high no. of connections in sleep mode.what may be the root cause for the same. no conenction leak found.

  • mysql DB connections

  • reached to max limit

  • java web application

  • Network/Kernel issue

  • DB connection leak

Please Sign In or to post your comment or answer

Profile Image

Ram Lakshmanan

Hello Abhi!

 

 Greetings. Here are the potential issues which could cause DB connection leak:

 

1. Network/Kernel issue: May be there is a network/kernel issue, which is preventing the connections from terminating. Probably they are going in to CLOSE_WAIT, FIN_WAIT state and never terminating. You can confirm this by issuing 'netstat' command on the machine where tomcat is running. It will show how many connections are established to your MySQL DB and what TCP/IP state they are in.

 

2. Application is not closing connection in certain scenarios: May be for certain type of DB calls, your application isn't closing the connections. Sometimes I have seen when there is an exception in the code, developers misses to close connection. It could be quite possibly happening in your application.  

3. Threads are holding on to connection: Sometimes certain SQL call might take long time to complete. In such circumstances threads will be still continuing to hold on to the connection. In that scenario also connection count will continue to grow. You might want to take thread dump from the application and see whether threads are holding on to the connections.

4. Bug in the DB Connection Pool: May be there is a bug in the DB connection pool which is causing the connection to leak.  What connection pool and what version are you using? 

 

Also another question for you. From where (i.e. what tool) are you using to observe that connection count is increasing?

 

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • mysql DB connections

  • reached to max limit

  • java web application

  • Network/Kernel issue

  • DB connection leak