question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement CommandTimeout

See original GitHub issue

1. Implement DefaultCommandTimeout in the connection string

Connection String Documentation

2. Implement CommandTimeout in MySqlCommand

MySqlCommand cmd = new MySqlCommand();
cmd.CommandTimeout = 60;

MySqlCommand Documentation:

Implementation Notes:

MySQL Connector/Net 6.2 introduced timeouts that are aligned with how Microsoft handles SqlCommand.CommandTimeout. This property is the cumulative timeout for all network reads and writes during command execution or processing of the results. A timeout can still occur in the MySqlReader.Read method after the first row is returned, and does not include user processing time, only IO operations. The 6.2 implementation uses the underlying stream timeout facility, so is more efficient in that it does not require the additional timer thread as was the case with the previous implementation.

It sounds like Oracle’s implementation of CommandTimeout is setting Socket.SendTimeout and Socket.ReceiveTimeout. They start at the timeout value (e.g. 30 seconds) and subtract only time spent in I/O. This becomes the send or receive timeout for the next socket command.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:35 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
bgraingercommented, Oct 22, 2017

Implemented in 0.29.0.

1reaction
caleblloydcommented, Oct 3, 2016

Not sure what you mean by “Server ID”

The server_id global variable is used in replicated setups. It is required to be unique for replication to start, but looks like it’s not sent in the initial handshake packet.

There is a “Replication” option that can be set in the connection string. If this was set, we could run a SELECT @@server_id query as part of the connection open process.

The worry is that without comparing server_id before killing a query from a separate connection on a replicated setup, we could actually be killing a valid query on a different server that has the same connection_id.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SqlCommand.CommandTimeout Property
This property is the cumulative time-out (for all network packets that are read during the invocation of a method) for all network reads...
Read more >
c# - Increasing the Command Timeout for SQL command
it takes this command about 2 mins to return the data as there is a lot of data. Probably, Bad Design. Consider using...
Read more >
CommandTimeout - ADO.NET in a Nutshell [Book]
Configures the time in seconds that a command will wait once you execute it. If the command hasn't completed once the timeout is...
Read more >
ADO CommandTimeout Property
The CommandTimeout property sets or returns the number of seconds to wait while attempting to execute a command, before canceling the attempt and...
Read more >
Setting the command timeout with the latest .NET SqlClient
SqlClient, it is now possible to set the default command timeout via the connection string. Now you can work around timeout issues simply...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found