-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apparent connection leak detected #1209
Comments
@kumar-cherry HikariCP v2.6.1 is a bit old, I recommend upgrading to v3.x. More concerning is that Slick v2.1.0 was released in 2014, and has undergone an extensive re-write of the connection handling code. Many issues like transaction deadlocks, pool exhaustion, async issues, and even connection leaks have been fixed in newer versions of Slick. |
@brettwooldridge thanks for Reply. I will upgrade my version, val ds = new HikariDataSource() Regarding pool config above mention is enough, any thing specifically want to consider. |
@kumar-cherry After more log analysis, I have a further conclusion ... with respect to the pool, I do not see any issues. I do observe a strange pattern in your logs though...
Those timestamps are far too regular. Something is borrowing a connection, and holding on to it for one minute. We cannot see the "borrow" action in the log, but we can infer it:
Do not borrow a connection and hold it for one minute. |
@brettwooldridge Sorry for comment closed one. I have missed some line of log, 2018-07-20 13:36:37 DEBUG HikariPool {com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator call} - HikariPool-4 - Added connection org.postgresql.jdbc4.Jdbc4Connection@470e6501 2018-07-20 13:37:07 WARN ProxyLeakTask {com.zaxxer.hikari.pool.ProxyLeakTask run} - Connection leak detection triggered for org.postgresql.jdbc4.Jdbc4Connection@470e6501, stack trace follows 2018-07-20 13:37:37 INFO ProxyLeakTask {com.zaxxer.hikari.pool.ProxyLeakTask cancel} - Previously reported leaked connection org.postgresql.jdbc4.Jdbc4Connection@470e6501 was returned to the pool (unleaked) As my understanding, please correct me if anything wrong,
Question: How the Leaked connection added in Pool?
To solve this what should I do? Thanks @brettwooldridge , |
This connection was likely added because a client thread was requesting a connection...
... so it was borrowed immediately. Thirty-seconds later, when it was not yet returned, the "leak" was reported.
After another thirty-seconds, the connection is returned ("unleaked"):
I don't know how I can state this more clearly, somewhere in your code you are borrowing a connection and keeping it out of the pool for exactly one minute, then closing it. Basically it looks like: Connection con = ds.getConnection();
Thread.sleep(60000);
con.close(); That is the equivalent of what is going on. Because the logs show this occurring every minute ... Don't do that. Do not acquire a Connection, keep it for a minute, and then close it. Instead, acquire a Connection, run a query or queries, and then immediately close it. |
rule-engine-log-trim.pdf
Environment
Current Production Tech Stack:
scala - 2.10.4
slick - 2.1.0
hikari - 2.6.1
Datasource Configuration:
val ds = new HikariDataSource()
ds.setDriverClassName("")
ds.setJdbcUrl("jdbc:postgresql://localhost:5432/somedb")
ds.setUsername("dbuser")
ds.setPassword("password")
ds.setMinimumIdle(2)
ds.setMaximumPoolSize(4)
ds.setIdleTimeout(600000)
ds.setLeakDetectionThreshold(30000)
ds.setConnectionTimeout(30000)
We are working multi-tenant model, each tenant has their own DB we are running more than 6 months in production, This month we are facing connection leak problem two times randomly (some connection pool).
Following points noted from log:
I have attached log file. I have marked in red colour.
@brettwooldridge we are expecting your help to solve this problem. should we focus on configuration or code level anything to be done for this permanent solutions.
Thanks @brettwooldridge .
The text was updated successfully, but these errors were encountered: