I have a Java application connecting to a MySQL database (> 25 Gb MyISAM Engine) using JDBC mysql-connector-java-5.1.6. When I separate the database and put it on a separate server than the application it hangs in the JDBC driver after a random time and in random parts in the application. The application have a list of database connections that is used in a round-robin fashion. A connection could be used by several threads at the same time if a statement takes enough time so that a used connection is picked by another thread (I have implemented a connection pool, Apache DBCP, but that is not in use on this system yet).
This is some output from the JVM threaddump:
"RequestProcessor-114659" daemon prio=1 tid=0x896b0d30 nid=0x33c runnable [0x83eda000..0x83edb030] 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 <0x9218a720> (a com.mysql.jdbc.util.ReadAheadInputStream) at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2938) ...
The dump is much longer than this but I think the vital part is here. The thread is waiting on socketRead ie some kind of response from the database server. There is no database query being executed when this happens so it shouldn't wait for a response from the database.
Have anyone else encountered any similar problem? Any ideas on what the problem could be?
I read something about that the use of a jdbc connection from several threads at the same time could trigger these kinds of locks so that is something I will test by deploying a version with a proper database pool.