Hi Sarvesh,
Most of the threads (127+ threads) in your application are in waiting (not locked). Here are a few suggestions.
1) Your application is very likely to have a connection leak. Somewhere your code is opening a database connection but not closing it. Please use the try-with-resources pattern whenever you checkout connections.
2) I think when you use hibernate it manage the connection state by itself. Basically, it closes the connection when the sessionFactory.close() method is invoked. The hibernate sessionFactory doesn't return a connection to the pool until it is closed. Can you check the value of hibernate.connection.release_mode property in your configuration if you have configured?
3) You can use JMX and monitor the c3p0 datasources state.
4) Please try setting c3p0 params unreturnedConnectionTimeout and debugUnreturnedConnectionStackTraces to see if there is a leak. For more details visit below links -
http://www.mchange.com/projects/c3p0/#configuring_to_debug_and_workaround_broken_clients http://www.mchange.com/projects/c3p0/#unreturnedConnectionTimeout http://www.mchange.com/projects/c3p0/#debugUnreturnedConnectionStackTraces
5) Also try setting checkoutTime param for c3p0 which specifies the amount of time a client should wait for acquiring a connection from the connection pool. See
http://www.mchange.com/projects/c3p0/#checkoutTimeout
6) To debug c3p0 issues, you may want to capture config information that c3p0 dumps to logs at INFO level on the pool initialization.
7) You may also face this kind of issue when DB connection pool size < active threads.
For example, connection pool 10 connections and 35 active threads which get connections from the pool. c3p0 pool stuck after 10 connections open and after with small delay c3p0 pool stuck and all threads become waiting for the next connection from the pool. Threads that keep a connection open can't return it to the pool as the pool is stuck and other threads can't get connection from the pool.
Edit your Comment