-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Slick 3.0 transactionally deadlocks #1274
Comments
We are also suffering from this issue. I took the time to make a quick project which demonstrates the issue: https://github.com/kwark/slick-deadlock The issue not only occurs when using transactionally but also when using withPinnedSession The numThreads configured for 2 slick threads, which results in a Hikari connectionPool of 10 connections. However when the number of simultaneous task is high enough (in this case 20), it looks like the two slick threads are hanging and waiting for a connection from the pool. "h2mem1-2" #17 daemon prio=5 os_prio=31 tid=0x00007f834d3d0800 nid=0x6303 waiting on condition [0x0000700001c69000] "h2mem1-1" #16 daemon prio=5 os_prio=31 tid=0x00007f834e2ec800 nid=0x6103 waiting on condition [0x0000700001b66000] But there are no free connections anymore according to the HikariCP logging: [HikariCP connection filler (pool h2mem1)] DEBUG com.zaxxer.hikari.pool.HikariPool - After fill pool stats h2mem1 (total=10, inUse=10, avail=0, waiting=2) |
Is there any workaround? I think this is a big problem for a production enviornment. I have suffered from it many times and had to restart the whole application. |
We are also suffering from this issue. |
@MrPelle How to use an |
@szeiger I think there is something wrong with slick exection model. You may look at the simple benchmark (Source Code) I've made for testing very simple (non-)transaction operations. Execution time grow rapdily as concurrency level increase. def trans(userId: Long, order: Order) = DB.run {
val mutateIO = sqlu"update user set remain = remain - ${order.totalFee} where id = ${userId}"
val insertIO = Orders += order
insertIO >> mutateIO
} |
+1. It would also be nice to know when this bug was introduced, so an earlier version could be used as a workaround. |
Slick 2.x doesn't seem to be affected, but the whole Slick 3.x branch is. |
Workaround until we fix this properly (as explained in the mailing list thread): Set the maximum number of connections larger than thread pool size + queue size. |
Is there a roadmap when this fix is going to be part of official Slick ? |
I experimenting the same problem during a massive insert. This is my actor code.
|
Right now i'm trying with this configuration:
|
@utaladriz You can set
Since the detault is numThreads * 5 = 300, which is greater than numThreads + queueSize, there should not be any need to change it. |
I backported my slick deadlock fix (#1461) to 3.1.1 and published it to a bintray repo as version 3.1.1.1 If you are suffering from deadlocks you might want to try out that version. |
Fixed in #1461 |
Remove redundant test (see slick/slick#1274, fixed as of slick 3.2.0)
Hi,
When I try to execute multiple transactions in separate threads, it happens to cause deadlock.
This sample app always timeouts, without inserting any row in the test table.
However, it seems that the deadlock happens only in this constellation, as
transactionally
is not used:DBIOAction
:Could someone explain me what's happening, is this behavior intended, or am I missing something about transactions?
Also, I think it worths mentioning that I'm using Hikari connection pool, maybe it's related to that?
The text was updated successfully, but these errors were encountered: