java.sql.SQLException: Io exception: Broken pipe

This exception was reported to me by our testing team around 6 months back. We are using Mysql with Apache Tomcat server. We are using JDBC driver implementation given by MySql only.

The scenario was like following:

Solution used to work correctly the whole day and some times it didn’t show up in mornings. and when we check the logs we used to get this,

java.sql.SQLException: Communication link failure: java.io.IOException,underlying cause:Broken pipe

** BEGIN NESTED EXCEPTION **

java.io.IOExceptionMESSAGE: Broken pipe

STACKTRACE:

java.io.IOException: Broken pipe at java.net.SocketOutputStream.socketWrite(Native Method) at
java.net.SocketOutputStream.write(SocketOutputStream.java:95)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:78)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:136)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1758)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1721)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1144)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1272)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1218)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2233)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2181)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1158)
at net.vsms.vsmsbackend.test.TestBed.(TestBed.java:82) 
at net.vsms.vsmsbackend.test.TestBed.main(TestBed.java:820)

** END NESTED EXCEPTION **

 at java.lang.Throwable.(Throwable.java:96) at java.lang.Exception.(Exception.java:44) 
at java.sql.SQLException.(SQLException.java:45) 
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1779) 
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1721) 
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1144) 
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1272) 
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1218) 
at com.mysql.jdbc.Connection.execSQL(Connection.java:2233) 
at com.mysql.jdbc.Connection.execSQL(Connection.java:2181) 
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1158) 
at net.vsms.vsmsbackend.test.TestBed.(TestBed.java:82) 
at net.vsms.vsmsbackend.test.TestBed.main(TestBed.java:820)

It was clear that it has some thing to do with timeout but hard to reproduce because as we restart the MySql server it used to work fine during the day or even next day.

Finally we got a description of bug reported in MySQL JDBC driver which was because of substandard implementation of pool. Again the problem was imperfect exception handling by developers.

Work around for this is to use autoReconnect parameter in your connection string and make it TRUE.

I guess this will be fixed in next release. See the bug description here

Most Commented Posts

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)