Bug #56806 Default Command Timeout has no effect in connection string
Submitted: 15 Sep 2010 19:32 Modified: 13 Oct 2010 9:22
Reporter: Aren Cambre Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.3.4 OS:Windows
Assigned to: CPU Architecture:Any
Tags: entity framework

[15 Sep 2010 19:32] Aren Cambre
Description:
Default Command Timeout is supposed to be a value you can specify in a MySql connection string.

Per available documentation, if your Entity Framework 4.0's ObjectContext object's CommandTimeout is null, it's supposed to use the timeout of the "underlying provider". And this is backed up in the documentation: "...the default command timeout can be changed using the connection string option Default Command Timeout." (http://dev.mysql.com/doc/refman/5.1/en/connector-net-programming-mysqlcommand.html)

In fact, Default Command Timeout in the connection string has no effect. No matter what you specify, the timeout stays at 30 seconds. The only way I can find to change this behavior is to change context.CommandTimeout in my application code.

How to repeat:
Create MySql DB that has a query that takes well over 30 seconds.

Create .Net Framework 4.0 app that uses Connector/Net 6.3.4 and Entity Framework to access the data. Don't alter any settings related to timeouts.

Execute lengthy query. You'll get a System.Data.EntityCommandExecutionException with an inner exception of "MySql.Data.MySqlClient.MySqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."

Now add this to the connection string in App.Config, between the HTML-encoded quotes ("): Default Command Timeout=180

Rerun the app. (If you're not running through the debugger, make sure your app got the latest version of app.config.) It will still time out with an exception at 30 seconds.

Now return to the application and change the ObjectContext object's CommandTimeout to 180. Recompile and re-run the app. Now it finally runs longer than 30 seconds.

Suggested fix:
Honor the Default Command Timeout if it's in the connection string.
[7 Oct 2010 21:13] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/120306

840 Reggie Burnett	2010-10-07
      - fixed MySqlCommand.Clone so that the default command timeoout functionality is not disabled when
        you clone a command (bug #56806)
       The problem was that MySqlCommand.CommandTimeout has a hidden function.  If the underlying value is 0 then the default value is returned, otherwise the underlying value is returned.  In our Clone method we were using CommandTimeout which would return the default value rather than the underlying value.  This would, in effect, disable our default command timeout which relied on the underlying value still being 0.
[7 Oct 2010 21:16] Reggie Burnett
fixed in 6.0.8, 6.1.6, 6.2.5, 6.3.5+
[11 Oct 2010 18:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/120528

843 Reggie Burnett	2010-10-11
      incorporating new default command timeout handling into my clone patch (bug #56806)
[13 Oct 2010 9:22] Tony Bedford
An entry has been added to the 6.0.8, 6.1.6, 6.2.5, and 6.3.5 changelogs:

Setting the Default Command Timeout connection string option had no effect.