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 Method)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(
- locked <0x4a0fd808> (a com.mysql.jdbc.util.ReadAheadInputStream)
at com.mysql.jdbc.MysqlIO.readFully(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.ConnectionImpl.execSQL(
- locked <0x4a0fe708> (a java.lang.Object)
at com.mysql.jdbc.PreparedStatement.executeInternal(
at com.mysql.jdbc.PreparedStatement.executeQuery(
- locked <0x4a0fe708> (a java.lang.Object)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(

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

Written By
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.