0

I have specified command_timeout for 4 seconds.


But when I run the application, the command takes something about 8-12 seconds before it times out.


I also specified connection timeout in MySQL connection string, but with no luck

default command timeout=4

It works for MsSqll and Oracle well, but for MySQL not.

Is there any way how to specify the timeout?

I found the issue there https://forums.mysql.com/read.php?38,634568,634568 but with no answer.

Edit

Code Sample

...         
DataTable outputNodes = new DataTable();
Stopwatch sw = new Stopwatch();
cmd.CommandTimeout = 4;
sw.Start();
var a = cmd.ExecuteReader();
sw.Stop();
ex_time = sw.Elapsed;
sw.Reset();
outputNodes.Load(a);
CloseConnection();
...
4
  • 1
    MySQL Connector version? Commented Jan 31, 2018 at 15:10
  • You can also use something like MySqlCommand cmd = new MySqlCommand(); cmd.CommandTimeout = 4; Commented Jan 31, 2018 at 15:13
  • @Hackerman MySQL Connector version 6.9.9.0 Commented Jan 31, 2018 at 15:18
  • @Hackerman I also specified cmd.CommandTimeout = 4. Result still same. Commented Jan 31, 2018 at 15:19

1 Answer 1

1

This is probably a bug in Connector/NET. I've run into a number of bugs with CommandTimeout, e.g., bug 88124, bug 87307. I thought I even remembered filing a bug report about MySqlCommand taking 2× CommandTimeout before it actually timed out (which sounds like your situation), but I can't find it now (if I actually did file it).

If you have a consistent repro, I'd suggest filing a bug at bugs.mysql.com.

And if you have the flexibility to change drivers, try MySqlConnector, which has a much more robust CommandTimeout implementation.

Sign up to request clarification or add additional context in comments.

1 Comment

I found some of the bug reports too but from 2015. I thought it might be resolved now. Thanks for the information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.