I am having a strange issue with an exisitng servlet based applications (a litte old one).
I cannot get any servlets to complete operation, if it has a mysql prepared statement running slower than 10 seconds (I only have prepared statements in this app).
I dont have a problem with faster queries (less than 10 second).
catelina.out does not have any trace nor the browser interface. When I inspect the browser request through fiddler it shows
“This session is not yet complete. Press F5 to refresh when session is
complete for updated statistics. Request Count: 1 Bytes Sent:
437 (headers:437; body:0) Bytes Received: 0 (headers:0; body:0)”
MySQL “SHOW FULL PROCESSLIST” command shows the prticular socket connection (of a slow query) running for about 12 seconds with COMMAND=”Execute” and STATE=”Sending Data”, then changing to COMMAND=”Sleep” and STATE=”” and stays like this for a long time (more than 500 seconds).
Ideally this connection should not remain as a SLEEP for such a long time, but close after completion of sending data.
netstat -ab command shows the same connection as ESTABLISHED under tomcat6.exe and mysqld.exe.
Ideally this should stay as TIME_WAIT once the query execution is finished till the “TcpTimedWaitDelay” value.
Expected payload of this query is pretty nominal (around 2kbytes).
MySQL connect_timeout=100 and Tomcat connectionTimeout=”100000″ (for the port 8000 which I am running the app).
One thing I did not try to change is the JDBC DriverManager.setLoginTimeout property, since it is only concerned until getting the connection.
This app was working quite well until a couple of days back. but I do not have any statistics with me on the query execution time during those days.
I am running windows 2008 R2 std edition, tomcat 6 and MySQL 5.5.
I cannot pinpoint this behaviour to any cause. appreciate your help very much.
It seems to be an issue related to the MySQL connector. We were using the old connector (version 3.1.x) . Latest stable version(5.1.20) fixed the issue.