Bug #32246 JDBC driver (ConnectorJ) hangs instead of propagating error message
Submitted: 9 Nov 2007 20:05 Modified: 13 Nov 2007 12:05
Reporter: Larry Brunelle Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: error message not propagated, JDBC hangs

[9 Nov 2007 20:05] Larry Brunelle
Description:
Under several conditions interacting with stored routines,
the JDBC driver hangs instead of reporting the error condition.
This behavior occurs in at least the following cases.  (There
may be others . . .)

o The stored routine gets a wrong number of arguments.

o The stored routine references a wrong column. 

o The stored routine experiences a constraint violation.

The last two conditions, and especially the last, are the
more serious, for they can be encountered after deployment,
on code that was correct the day deployed.  The last is, of
course, entirely data dependent; the second, vulnerable to
schema changes.

Marc Gfeller has provided some simple Java test cases, shortly
to be attached.

The behavior has been observed with both 
mysql-connector-java-5.1.5-bin.jar and
mysql-connector-java-5.1-nightly-20071109-bin.jar

It seems to be new since
mysql-connector-java-5.0.8-bin.jar.
 

How to repeat:
Invoke the attached test cases thus:
java -cp $PWD:$PWD/mysql-connector-java-5.0.8-bin.jar TestCaseX $MY_SQL_URL

Descriptions:
-------------

TestCase2.java - Creates a function with an invalid column
                 in the select list and calls that function.

TestCase3.java - Creates a function that inserts into a table 
                 with a foreign key constraint and calls the 
                 function to insert both valid and invalid data.

TestCase4.java - Creates a function that is called with an 
                 invalid number of arguments.
[9 Nov 2007 20:06] Larry Brunelle
Java test case 2

Attachment: TestCase2.java (application/octet-stream, text), 2.27 KiB.

[9 Nov 2007 20:06] Larry Brunelle
Java test case 3

Attachment: TestCase3.java (application/octet-stream, text), 2.47 KiB.

[9 Nov 2007 20:07] Larry Brunelle
Java test case 4

Attachment: TestCase4.java (application/octet-stream, text), 2.35 KiB.

[9 Nov 2007 20:25] Larry Brunelle
Please note:  The instructions to reproduce show only the
use of 5.0.8.  These should have included the invocation
of  5.1.x.   (Sorry.)
[9 Nov 2007 21:38] Mark Matthews
Test case #4 seems to be a different bug, so I've split it out to Bug#32251.
[9 Nov 2007 21:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37492
[9 Nov 2007 21:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37493
[9 Nov 2007 21:54] Mark Matthews
Fix will be released in 5.1.6, nightly snapshot builds with the fix will be available at http://downloads.mysql.com/snapshots.php#connector-j after 00:00 GMT Nov 10.

Thanks for the bug report!
[13 Nov 2007 12:05] MC Brown
A note has been added to the 5.1.6 changelog: 

When unpacking rows directly, we don't hand off error
      message packets to the internal method which decodes them correctly, so
      no exception is raised, and the driver than hangs trying to read rows
      that aren't there. This tends to happen when calling stored procedures, as
      normal SELECTs won't have an error in this spot in the protocol unless an
      I/O error occurs.
[19 Nov 2007 0:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38019
[19 Nov 2007 2:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38024
[8 May 2008 19:51] Eric DeCosta
"This tends to happen when calling stored procedures, as normal SELECTs won't have an error in this spot in the protocol unless an I/O error occurs."

Any chance that a SELECT...FOR UPDATE could produce the same problem?