How is leakTimeMinutes config used in Ebean to reset leaked connections

216 views
Skip to first unread message

ruchita venugopal

unread,
Mar 16, 2017, 12:47:14 AM3/16/17
to Ebean ORM
I am new to Ebean and hence I have been exploring the code myself to understand a recent issue that occurred on our production few weeks back

There was an issue on our application related to database connection pool. We are relying on DataSourcePool to take care of our connection pool. Our mysql database had a memory replacement(it was not performed offline as expected) and it had unintended effect of  closing all the live sessions with our application boxes. The result was that our application was not able to recover back even after 20 minutes(it kept throwing the below exception) at which point of time, we had to restart all the application hosts to purge all the database connections  and recreate new connections

java.sql.SQLException: Unsuccessfully waited [1800] millis for a connection to be returned. No connections are free. You need to Increase the max connections of [50] or look for a connection pool leak using datasource.xxx.capturestacktrace=true

      type:  class javax.persistence.PersistenceException


My question is, how is the connection pool supposed to handle such a scenario? Is not it supposed to take care of cleaning the leaked connections.


Also, I have been going through the code. However I do not understand how the DataSourcePool.closeBusyConnections is configured to free the leaked connections.

Rob Bygrave

unread,
Mar 22, 2017, 3:57:18 AM3/22/17
to ebean@googlegroups

> My question is, how is the connection pool supposed to handle such a scenario? Is not it supposed to take care of cleaning the leaked connections.

There is a validation test on connections when they throw a SQLException and there is also a periodic background validation test.  When the validation test fails that triggers a reset of the connection pool where all idle connections are closed and busy connections created prior to the reset point are closed when they are returned to the pool.  The pool creates new connections after the reset.


With the above it actually sounds like there is a real connection pool leak (as you obviously didn't have connection errors or connection validation errors).

What you need to do is set captureStackTrace = true.  This turns on the capture of the stack trace used to obtain connections. Then on shutdown etc there are log entries reporting where connection leaks are occurring in the code.






--

---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages