Bug #64700 | Deadlock during Connection.close() | ||
---|---|---|---|
Submitted: | 20 Mar 2012 3:25 | Modified: | 24 Jul 2012 15:48 |
Reporter: | Przemek Bruski | Email Updates: | |
Status: | Won't fix | Impact on me: | |
Category: | Connector / J | Severity: | S2 (Serious) |
Version: | 5.1.18 | OS: | Any |
Assigned to: | Alexander Soklakov | CPU Architecture: | Any |
[20 Mar 2012 3:25]
Przemek Bruski
[21 Mar 2012 17:02]
Mark Matthews
The driver used to do just that, and c3p0 would deadlock itself too then. Getting database metadata, and grabbing a table list isn't the best "live" check in the world, it can be very expensive. You can probably get better performance from "preferredTestQuery=/* ping */ SELECT 1" in your C3p0 configuration. If you still must use c3p0's getTables() connection test method, I'd suggest adding "useDynamicCharsetInfo=false" to your JDBC url to see if it clears up this problem? (it will prevent the driver from having to issue a query to produce this result set). You may also consider talking to the c3p0 maintainers, and have them handle tear-down of connections when the pool is closing down or expiring them by using the abort() method on Connection. It was put there just for this purpose.
[24 Jul 2012 15:48]
Mark Matthews
Viable workaround.
[25 Jun 2013 13:09]
Triguna Mutuguppe Sripathi
I am using c3p0-0.9.1 and/or MySQL Connector/J 5.1.22 and getting the exact same issue. Following is the details of jstack from my tomcat: Found one Java-level deadlock: ============================= "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2": waiting to lock Monitor@0x00000000075a8e60 (Object@0x00000000c2604040, a com/mysql/jdbc/JDBC4Connection), which is held by "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0" "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0": waiting to lock Monitor@0x00000000075a8488 (Object@0x00000000c2616238, a com/mysql/jdbc/JDBC4ResultSet), which is held by "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2" This causes my application to break, is there a way to resolve this? Status says Won't fix? Thanks Triguna
[25 Jun 2013 13:10]
Triguna Mutuguppe Sripathi
I am not sure if this deadlock is during Connection.close as jstack did not give me any such information.
[2 Oct 2014 22:26]
Rafal Rusin
Mark Matthews, there's no abort on java.sql.Connection (only in JDBC4). Also since MySQL connector implementation does synchronization, it would be nice if the order of obtaining locks was fixed, just like Przemek Bruski recommended. For other deadlock cases, which you mentioned, there need to be separate tickets.