Bug #28635 Communications link failure due to underlying exception
Submitted: 23 May 2007 22:43 Modified: 25 May 2007 8:01
Reporter: Jeff Smith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.15 OS:Linux
Assigned to: CPU Architecture:Any

[23 May 2007 22:43] Jeff Smith
Description:
I was running this block of code in a loop (100 times) and it worked sometimes and failed sometimes under MySQL. Under HSQL, it always succeeds.

java.sql.PreparedStatement stmt = con.prepareStatement(
"SELECT MODEL_TASK_TYPE_ID FROM MODEL_TASK_TYPE " +
"WHERE MODEL_TASK_TYPE=? AND MODEL_TYPE=? AND USER_ID=? AND COMPUTER_ID=?");
stmt.setString(1, taskName);
stmt.setString(2, modelType);
stmt.setInt(3, userID);
stmt.setInt(4, computerID);
java.sql.ResultSet rs = stmt.executeQuery();

I got the same error a lot of you did:

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.io.EOFException

Two Clues To The Problem:
------------------------
1) The simple select statement above always succeeded when I set a parameter to a value that would match NO rows. For example, if I set the COMPUTER_ID to 9999, I never got an exception.
2) The simple select always succeeded when I dropped a unique constraint on 4 of the columns in the table. No constraint = works.

For now, my hack solution is to leave off the unique key (I still have the foreign keys defined).

Given my clues, it seems to me that the bug lies in MySQL version 5.0.15, not in the Connector/J JDBC driver. I may ask my SysAd to install the latest version to see if that fixes the problem. By the way, I've tried all the versions of the JDBC driver--it makes no difference.

MySQL 5.0.15 under Linux
Java 5 running under Windows
MySQL Connector/J 5.06

-Jeff Smith

How to repeat:
Create similar table with a unique key on 4 columns and multiple foreign keys and run select statement on it many times, from multiple runs of the JVM. You'll notice intermittent failures.
[24 May 2007 4:35] Valeriy Kravchuk
Thank you for a problem report. Please, try to repeat with a newer version, 5.0.41. 5.0.15 is very old. Then, in case of the same problem, please send the results of:

EXPLAIN SELECT MODEL_TASK_TYPE_ID FROM MODEL_TASK_TYPE 
WHERE MODEL_TASK_TYPE=? AND MODEL_TYPE=? AND USER_ID=? AND COMPUTER_ID=?;

with ? replaced by usual values you use. Send the results of:

SHOW CREATE TABLE MODEL_TASK_TYPE;
SHOW TABLE STATUS LIKE 'MODEL_TASK_TYPE';
CHECK TABLE MODEL_TASK_TYPE;
[24 May 2007 23:02] Jeff Smith
I updated MySQL to version 5.0.41 and the problem went away
[25 May 2007 8:01] Valeriy Kravchuk
Closed as not repeatable with 5.0.41.