Bug #33848 Application freeze on socketRead0
Submitted: 13 Jan 2008 16:58 Modified: 29 Jul 2008 10:58
Reporter: Salvatore Gerace Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.0.8 OS:Any
Assigned to: CPU Architecture:Any
Tags: socketRead0, tcpRcvBuf

[13 Jan 2008 16:58] Salvatore Gerace
Description:
My application freeze when make queries see stack:

Thread [AWT-EventQueue-0] (Suspended)
SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method]
SocketInputStream.read(byte[], int, int) line: not available
ReadAheadInputStream.fill(int) line: 113
ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(byte[], int, int) line: 160
ReadAheadInputStream.read(byte[], int, int) line: 188
MysqlIO.readFully(InputStream, byte[], int, int) line: 2329
MysqlIO.nextRowFast(Field[], int, boolean, int, boolean, boolean, boolean) line: 1583
MysqlIO.nextRow(Field[], int, boolean, int, boolean, boolean, boolean, Buffer) line: 1375
MysqlIO.readSingleRowSet(long, int, int, boolean, Field[]) line: 2708
MysqlIO.getResultSet(StatementImpl, long, int, int, int, boolean, String, boolean, Field[]) line: 459
MysqlIO.readResultsForQueryOrUpdate(StatementImpl, int, int, int, boolean, String, Buffer, boolean, long, Field[]) line: 2411
MysqlIO.readAllResults(StatementImpl, int, int, int, boolean, String, Buffer, boolean, long, Field[]) line: 1657
MysqlIO.sqlQueryDirect(StatementImpl, String, String, Buffer, int, int, int, boolean, String, Field[]) line: 2036
JDBC4Connection(ConnectionImpl).execSQL(StatementImpl, String, int, Buffer, int, int, boolean, String, Field[], boolean) line: 2543
JDBC4PreparedStatement(PreparedStatement).executeInternal(int, Buffer, boolean, boolean, Field[], boolean) line: 1737
JDBC4PreparedStatement(PreparedStatement).executeQuery() line: 1888
BatchingBatcher(AbstractBatcher).getResultSet(PreparedStatement) line: 186
QueryLoader(Loader).getResultSet(PreparedStatement, boolean, boolean, RowSelection, SessionImplementor) line: 1787
QueryLoader(Loader).doQuery(SessionImplementor, QueryParameters, boolean) line: 674
QueryLoader(Loader).doQueryAndInitializeNonLazyCollections(SessionImplementor, QueryParameters, boolean) line: 236
QueryLoader(Loader).doList(SessionImplementor, QueryParameters) line: 2220
QueryLoader(Loader).listIgnoreQueryCache(SessionImplementor, QueryParameters) line: 2104
QueryLoader(Loader).list(SessionImplementor, QueryParameters, Set, Type[]) line: 2099
QueryLoader.list(SessionImplementor, QueryParameters) line: 378
QueryTranslatorImpl.list(SessionImplementor, QueryParameters) line: 338
HQLQueryPlan.performList(QueryParameters, SessionImplementor) line: 172
SessionImpl.list(String, QueryParameters) line: 1121
QueryImpl.list() line: 79

This not happens in the same query but occasionally when query retrieves 100 or more rows!

I have try some mysql JDBC drivers but problem exist in all versions!

Someone can help me?

thx

My application use:
hibernate 3.2, mysql 5.0.45-communuty-nt, mysql-connector-java-5.0.8

How to repeat:
Simple make a query whit 100 or more result rows
If I use traceProtocol=true can't reproduce the problem, maybe timing issue?

Suggested fix:
I use socketTimeout=60000 and handle the exception for sbloking the thread but I not have find any fix!
[13 Jan 2008 17:00] Salvatore Gerace
This bug is like Bug #9515, but in this case all connection are closed! I use only one connection and the problem is present!
[21 Jan 2008 19:13] Noam Ambar
It also happened to me after upgrading from 5.0.5 to 5.1.5. The system is up and running for ~1-2 days and then it hangs - same stack trace. Is there any workaround for this?
[21 Jan 2008 19:20] Noam Ambar
"Temporary Alarmclock Thread" prio=10 tid=0x0000000000fcac00 nid=0x51af runnable [0x0000000046c69000..0x0000000046c6ab10]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:157)
        at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
        - locked <0x0000002abb69b900> (a com.mysql.jdbc.util.ReadAheadInputStream)
        at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2329)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2830)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2763)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3299)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:894)
        at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1382)
        at com.mysql.jdbc.RowDataDynamic.nextRecord(RowDataDynamic.java:409)
        at com.mysql.jdbc.RowDataDynamic.next(RowDataDynamic.java:388)
        at com.mysql.jdbc.RowDataDynamic.close(RowDataDynamic.java:166)
        - locked <0x0000002abc01c518> (a java.lang.Object)
        at com.mysql.jdbc.ResultSetImpl.realClose(ResultSetImpl.java:7466)
        at com.mysql.jdbc.ResultSetImpl.close(ResultSetImpl.java:881)
        at com.mysql.jdbc.StatementImpl.realClose(StatementImpl.java:2227)
        at com.mysql.jdbc.PreparedStatement.realClose(PreparedStatement.java:2647)
        at com.mysql.jdbc.ConnectionImpl.closeAllOpenStatements(ConnectionImpl.java:1481)
        at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4216)
        at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1453)
        - locked <0x0000002aba784a00> (a com.mysql.jdbc.JDBC4Connection)
[2 Feb 2008 9:24] Salvatore Gerace
I have find a valid FIX:
set bigger tcp receiver buffer, "tcpRcvBuf=100000" this option in the url fix my problem.

I think is a simple case of buffer overflow.

Best regard.
[29 Jul 2008 10:58] Tonci Grgin
Guys, closing the bug report because:
  o) No test case was attached that can help me reproduce problem reported
  o) Viable workaround is found.

Thanks for your interest in MySQL.