Re: Connector/J "Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost."
Posted by: Dmitry Nezhevenko
Date: February 11, 2008 01:45PM

Hi Mark and thanks for your response. We are using commons dbcp DataSource. When I got these strange backtraces, I've tried to enable connection checking to datasource, using "mysql ping" (SELECT 1). And currently there are no such backtraces in logs. And also no performance improvements...

I've tried to do "kill -3 `pidof java`". There are a lot of threads that's waiting for socket' incomming data:

at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
- locked <0x4a0fd808> (a com.mysql.jdbc.util.ReadAheadInputStream)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2329)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2774)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2763)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3299)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
- locked <0x4a0fe708> (a java.lang.Object)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1888)
- locked <0x4a0fe708> (a java.lang.Object)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
....

Thera re no such queires in mysqladmin processlist output. Query is not time expensive (it takes less than second in standard mysql client). There are also no messages in mysql error log.

Behaviour is too strange. After restarting application it became working for some time (~1-2 hours). I think that application closes all connections since "mysqladmin processlist" shows same number of processes.

Average server load: ~ 80.878 queries per second.

I will try to add --log-warnings to server startup script tomorrow.

Options: ReplyQuote


Subject
Written By
Posted
Re: Connector/J "Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost."
February 11, 2008 01:45PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.