Description:
I'm seeing a hang in the JDBC driver when using the "explainSlowQueries" property.
I'm trying to do a debug run of my application and gather performance numbers for all the queries in the system. So I set the following JDBC connection properties:
props.put("profileSQL", "true");
props.put("logger", MySqlTraceLogger.class.getName());
props.put("slowQueryThresholdMillis", "0");
props.put("logSlowQueries", "true");
Everything works great. Then when I add the following line:
props.put("explainSlowQueries", "true");
and rerun the same test, my application hangs. I spent a few minutes debugging the problem. It looks like the EXPLAIN succeeds, but then the subsequent call to executeQuery() hangs. I copied the stack trace below.
---------------------
SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method]
SocketInputStream.read(byte[], int, int) line: not available
ReadAheadInputStream.fill(int) line: 105
ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(byte[], int, int) line: 148
ReadAheadInputStream.read(byte[], int, int) line: 176
MysqlIO.readFully(InputStream, byte[], int, int) line: 1899
MysqlIO.readPacket() line: 481
MysqlIO.readAllResults(Statement, int, int, int, boolean, String, Buffer, boolean, long, boolean) line: 1410
ServerPreparedStatement.serverExecute(int, boolean) line: 1133
ServerPreparedStatement.executeInternal(int, Buffer, boolean, boolean, boolean) line: 670
ServerPreparedStatement(PreparedStatement).executeQuery() line: 1024
DelegatingPreparedStatement.executeQuery() line: 205
How to repeat:
Set the following properties on the connection:
props.put("profileSQL", "true");
props.put("logger", MySqlTraceLogger.class.getName());
props.put("slowQueryThresholdMillis", "0");
props.put("logSlowQueries", "true");
props.put("explainSlowQueries", "true");
and run executeQuery() several times for a PreparedStatement.
Suggested fix:
Setting "explainSlowQueries" should not affect the functionality of the JDBC driver.