Bug #3654 ODBC timeouts doesn't work with MyODBC
Submitted: 4 May 2004 20:45 Modified: 9 Jan 2015 9:35
Reporter: d di (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S4 (Feature request)
Version:3.51.06 OS:Windows (Windows)
Assigned to: CPU Architecture:Any

[4 May 2004 20:45] d di
Description:
When using ODBC and specifying command timeouts, whenever the server does something bizarre, the call doesn't return after the timeout elapses but just blocks indefinitely.

How to repeat:
Create a .NET project.
Make an OdbcConnection to a MySQL server.
Create an OdbcCommand, set its CommandText to a query that you know will deadlock (or take more than eg. 50 seconds).
Set the CommandTimeout on the OdbcCommand to 10 seconds.

Execute the command.
The command doesn't return until long after the timeout has elapsed.

Suggested fix:
Make MyODBC throw an exception when the timeout elapses.

I personally don't care too much whether the query is really executed or not.
It would be nice if one could always count on the query execution having been cancelled when the timeout has elapsed, or if some information was given whether the query failed or succeeded later, but it's by no means important. The only crucial thing is that the call returns when the timeout specified has elapsed.
[25 Nov 2004 15:20] d di
We couldn't wait for a general fix, so we implemented a number of obnoxious workarounds in the different applications affected.. (priority changed to medium)
[11 Apr 2005 18:39] Mark Matthews
We can't implement this correctly until the server has timeouts (scheduled for the 5.1 timeframe).
[13 Sep 2007 18:05] Jim Winstead
This was not implemented in version 5.1 of the server, and is currently scheduled for some indefinite future version of the server (not 5.2 or 6.0, as far as I can tell).
[14 Sep 2007 9:14] d di
(Thanks for the update.)

What is the definition of "correctly" here?

Connector/NET and Connector/J has this feature, it seems..
[13 Mar 2014 7:12] Bogdan Degtyariov
It is possible to implement the command timeout without the server support.
The driver should start a thread, counting the time, which would kill the query from another connection if necessary. The approach is similar to the one used with SQLCancel() except the driver starts its own thread and initiates the connection (not the client).

If the server protocol supported command timeouts it would make the task a lot easier. The command timeout feature as described above would work with the delay (a new connection has to be established). So, the feature implemented with the driver has inaccurate functionality (connect could take seconds or tens of seconds) due to technical limitations.

Setting the Verified status, but Severity is lowered to S4 (feature request).