Search code examples
mysqlcommand-timeout

Update command timeout to 0 in mysql db configuration


How to update the command timeout in mysql database. I know how to do it at application level but I want to change the command timeout at db end. So that I have to change it only at one place. At application end I am using

"default command timeout = 0"

and it is working fine. But can anyone tell me how to do the same at db end?


Solution

  • The answer is: you cannot. Why? Because command timeout is specific to the MySQL .Net Connector:

    Sets the default value of the command timeout to be used. This does not supersede the individual command timeout property on an individual command object. If you set the command timeout property, that will be used. This option was added in Connector/Net 5.1.4

    As MySQL documentation on MySqlCommand object says:

    Prior to MySQL Connector/Net 6.2, MySqlCommand.CommandTimeout included user processing time, that is processing time not related to direct use of the connector. Timeout was implemented through a .NET Timer, that triggered after CommandTimeout seconds. This timer consumed a thread.

    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.

    So, before 6.2 the command timeout included client side processing time - this obviously cannot be taken into account on the server side.

    Since 6.2, the behaviour has changed and does not include client side processing time. However, it is now defined as "cumulative timeout for all network reads and writes". In MySQL server you can configure various timeouts, but those are not cumulative, nor apply to both reads and writes. There are separate read and write timeouts only. So, there is no mapping of this connector parameter to the MySQL configuration.