-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Connections not being returned to pool on transaction failure #445
Comments
@AlexLaviolette can you share your slick configuration? The number of threads used by Slick must be equal to the number of connections in the pool. |
I was just using the default configuration for slick. But after reading through slick/slick#1614 and some other discussions and trying several of the suggestions in there (including max_conns = num_threads) I am still running into this issue. My configuration before was:
I have since upgraded I also upgraded [warn] slick.util.AsyncExecutor - Having maxConnection > maxThreads can result in deadlocks if transactions or database locks are used. I configured slick as follows which stifled the warning message
However I am still encountering the error. In the discussion it seemed that if this fix only applied to So as a test, I switched to using an
Please let me know if anything sticks out to you, and thanks for responding! |
@AlexLaviolette thanks for the super-thorough explanations and tests. If you could provide a reproducer it'd be a great help to narrow down the issue. |
1 similar comment
This comment has been minimized.
This comment has been minimized.
I've put together a demo application here that replicates the issue https://github.com/AlexLaviolette/slick-demo. I have that deployed to a single machine (2GB RAM VM), connected to a single mysql db (1GB RAM VM). The script I run to reproduce it is in the repo under Hopefully this helps, let me know if you need anything else. |
I forked this and added the change referenced here to version 3.0.3. Unfortunately, this did not seem to fix my issue. |
We are experiencing this same issue. Dropping transactionally resolves the issue for us as well. @AlexLaviolette did you find a resolution for this in the end? |
For future searchers, we got to the bottom of this issue. Ours was actually caused by an error on our side. We'd flatmapped So it looked something like:
Because the outer transaction (where the Under load, this quickly lead to a deadlock - all connections were consumed by the outer transactions and none of the inner transactions (used by This is unlikely to be related to the problem faced by @AlexLaviolette but did have the same symptoms. |
Thanks a lot! Was looking for a hangup for 8 hours or so and slowly started to understand that it's related to nested transactions. What you describe is exactly what I have and after your description, working around it was trivial. Thanks mate! |
Currently on play 2.6 with play-slick 3.0.1, I’ve been running into an issue during load testing where the app is consuming tons of db connections from the pool and not returning them. I have narrowed it down to the use of
transactionally
, but have still not been able to pin point the exact cause.As proof of this, when I increase the db connection pool to 340 (our max_connections is 350), I can hit up to 28k rpm on one server. But with a pool of only 100, it almost instantly crashes under the same load with the connections timing out waiting for a connection from the pool. I can confirm that the database transactions are happening rapidly. When I enable hikari connection leak detection, I can see that some connections are taking > 60s to be returned, yet the database is showing nothing over 5 seconds. From everything I’ve read, we should be able to configure this to run with a much smaller pool. When I remove the use of
transactionally
, the behaviour of the pool returns to normal.Here are some logs:
with pool of 100 and transactionally enabled
with pool of 340 and transactionally enabled
Some errors with pool of 100 and transactionally enabled:
NewRelic is also showing these requests spending the majority of their time waiting on
com.zaxxer.hikari.HikariDataSource.getConnection()
Here is an example of the code that is causing the issue:
I am unable to reproduce this at low load or locally by manually causing the queries to fail. But something about using
transactionally
here is causing connections to not be returned to the pool for a very long time. There are reports thatPreviously reported leaked connection com.mysql.jdbc.JDBC4Connection@795acb1e was returned to the pool (unleaked)
but often after several minutes.The text was updated successfully, but these errors were encountered: