Bug #65990 Deadlock in JDBC driver
Submitted: 23 Jul 2012 22:24 Modified: 14 Oct 2012 18:37
Reporter: Bill Evans Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.20 OS:Solaris
Assigned to: Assigned Account CPU Architecture:Any
Tags: deadlock jdbc

[23 Jul 2012 22:24] Bill Evans
Description:
Here is the relevant part of the thread dump:

"pool-11-thread-8" - Thread t@77
   java.lang.Thread.State: BLOCKED
	at com.mysql.jdbc.ConnectionImpl.getCharacterSetMetadata(ConnectionImpl.java:2857)
	- waiting to lock <5fe736ed> (a com.mysql.jdbc.JDBC4Connection) owned by "Thread-4710" t@4901
	at com.mysql.jdbc.Field.getStringFromBytes(Field.java:717)
	at com.mysql.jdbc.Field.getOriginalName(Field.java:659)
	at com.mysql.jdbc.ResultSetImpl.buildIndexMapping(ResultSetImpl.java:751)
	at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1110)
	- locked <66caa42b> (a com.mysql.jdbc.JDBC4ResultSet)
	at org.jboss.resource.adapter.jdbc.WrappedResultSet.findColumn(WrappedResultSet.java:215)
	at org.hibernate.loader.custom.CustomLoader$Metadata.resolveColumnPosition(CustomLoader.java:562)
	at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:505)
	at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:524)
	at org.hibernate.loader.Loader.getResultSet(Loader.java:1820)
	at org.hibernate.loader.Loader.doQuery(Loader.java:696)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
	at org.hibernate.loader.Loader.doList(Loader.java:2233)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
	at org.hibernate.loader.Loader.list(Loader.java:2125)
	at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
	at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
	at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
	at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
...

--------------------
"Thread-4710" - Thread t@4901
   java.lang.Thread.State: BLOCKED
	at com.mysql.jdbc.ResultSetImpl.realClose(ResultSetImpl.java:7195)
	- waiting to lock <66caa42b> (a com.mysql.jdbc.JDBC4ResultSet) owned by "pool-11-thread-8" t@77
	at com.mysql.jdbc.ResultSetImpl.close(ResultSetImpl.java:909)
	at com.mysql.jdbc.StatementImpl.realClose(StatementImpl.java:2477)
	- locked <464e35d2> (a com.mysql.jdbc.JDBC4PreparedStatement)
	at com.mysql.jdbc.PreparedStatement.realClose(PreparedStatement.java:3108)
	- locked <464e35d2> (a com.mysql.jdbc.JDBC4PreparedStatement)
	at com.mysql.jdbc.ConnectionImpl.closeAllOpenStatements(ConnectionImpl.java:1634)
	at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4394)
	at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1411)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2711)
	- locked <5fe736ed> (a com.mysql.jdbc.JDBC4Connection)
	at com.mysql.jdbc.ConnectionImpl.rollbackNoChecks(ConnectionImpl.java:4863)
	at com.mysql.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:4749)
	- locked <5fe736ed> (a com.mysql.jdbc.JDBC4Connection)
	at org.jboss.resource.adapter.jdbc.local.LocalManagedConnection.rollback(LocalManagedConnection.java:97)

---------------------

I realize that this problem may already be known (Cases 64954 & 64700).  However, I would to know the following:

1. Is my problem, for sure, identical?
2. We reverted back to Connector/J version 5.1.13.  Will this fix this problem?  In other words, was this problem introduced sometime between versions 5.1.13 and 5.1.20?

Many thanks in advance for your help in this matter.

How to repeat:
Not entirely sure.
[24 Jul 2012 7:48] Tonci Grgin
Bill, you might wish to try Mark's suggestions from BUG#64700. Please inform us of result.
[24 Jul 2012 7:49] Tonci Grgin
Also, please do try latest version (5.1.21).
[24 Jul 2012 14:20] Bill Evans
Tonci,
After reading BUG#64700, I don't see what aspect of that bug helps me. You can see from my stack trace that I don't use c3p0.  Besides that it is not a simple matter to reproduce my issue.  For the same reason, trying 5.1.21 is not realistic. Also, since both BUG#64700 & BUG#64954 are still open it would seem unlikely that the problem is fixed.

The most important question I would like you to answer is: Can this issue happen in version 5.1.13?  Can you tell, by changes that were made, when the problem was introduced?

Thanks.
Bill
[24 Jul 2012 15:47] Mark Matthews
Bill,

"useDynamicCharsetInfo=false" should fix your issue if I'm reading your thread dump correctly.

The other bugs you reference aren't the same deadlock, a few may have been fixed with a change in the driver's locking model for 5.1.21, and all of them are either known issues with the JDBC specification requirements itself (addressed in later revisions), or anti-patterns used by some connection pools.
[14 Sep 2012 18:37] Sveta Smirnova
Bill,

please try Mark's suggestion and inform us about result.
[15 Oct 2012 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".