Timeout In Io Operation Mysql
Re: The timeout period elapsed prior to completion of the operation or the server is not responding. Open mysql sudo service mysql start; open command window. Sudo mysql -u username -p change the timeout. SET @@GLOBAL.interactivetimeout=31536000 restart server. Sudo service mysql restart windows timeout default is 31536000, you can choose the time you like And the way to see the timeout is show global variables like 'waittimeout'.
I was using a query which pulled back a large amount of populated navigation properties. Essentially it looked like this:
However, running this code produced an error
Timeout in IO operation
[TimeoutException: Timeout in IO operation] MySql.Data.MySqlClient.TimedStream.StopTimer() +168
MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count) +148
System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count) +262
MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count) +86
MySql.Data.MySqlClient.MySqlStream.LoadPacket() +110
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +59
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) +100
MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) +54
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +145
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +524
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +1939
How can I allow this query to have enough time to load?
Travis JTravis J2 Answers
What you need to do is increase the command timeout property.
In entity framework, the context used inherits from DbContext
. This is an IObjectContextAdapter
but does not contain easy access to the ObjectContext
methods. As such, in order to access the command timeout property, you will need to go through the Database
property of the DbContext
.
Now your query can have the time it needs in order to pull a larger amount of data if necessary.
Travis JTravis JMinecraft alien invasion mod 1.7.10. use this code in your Connection String in web.config
'default command timeout=0
'
Not the answer you're looking for? Browse other questions tagged c#mysqlentity-framework or ask your own question.
Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upHave a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
commented Mar 15, 2018
Connector/NET does not close connection when command timeout occurs . Instead, it cancels running query. If I remember correctly, SqlClient would not close a connection either. (Also JDBC drivers from both Oracle and MariaDB would keep the connection open whenever command times out). Only in MySqlConnector, the command timeout is fatal. |
referenced this issue Mar 15, 2018
OpenImprove command timeout handling #455
commented Mar 15, 2018
In MySqlConnector, the command timeout functionality doesn't cancel a running query but destroys the connection; see discussion at #67 (comment) and #455 (comment). The workaround is to either call I understand that this is a change from other ADO.NET connectors. I outlined a plan for improving it here: #455 (comment) |
commented May 3, 2018
This appears to have changed in 8.0.11; a timeout exception has now become I'm not saying that we shouldn't fix this (because Connector/NET now does the same thing), but just that MySqlConnector's behaviour may now be less of a breaking change. |
commented May 3, 2018
Executing MySql.Data 6.9.11Afterwards, MySql.Data 6.10.4 / 8.0.11Afterwards, |
Time Out In Io Operation Mysql Server
commented Nov 9, 2018
Mysql Set Timeout
Thanks @bgrainger for the info! Btw can we get our old TimeoutException back? I just lost a couple of time here on research until I finally found this topic. I don't think it's a problem to get the connection closed, but the exception itself is now misleading. |
commented Nov 9, 2018
MySqlConnector (this library) has never thrown a If you're referring to changes in Connector/NET (MySql.Data), that library is owned by Oracle and you need to report bugs/feature requests at https://bugs.mysql.com/. |