Timeout In Io Operation Mysql

04.08.2019
Timeout In Io Operation Mysql 3,3/5 6372 votes

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 J
66.4k31 gold badges161 silver badges229 bronze badges

2 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 JMysql connection timeout
66.4k31 gold badges161 silver badges229 bronze badges

Minecraft alien invasion mod 1.7.10. use this code in your Connection String in web.config

'default command timeout=0'

Aftab AhmedAftab Ahmed

Not the answer you're looking for? Browse other questions tagged c#mysqlentity-framework or ask your own question.

Timeout In Io Operation Mysql

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 up New issue

Have 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

Mysql

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

Open

Improve 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 MySqlCommand.Cancel() or use an ExecuteXAsync overload with a timeout-based CancellationToken.

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

Connector/NET does not close connection when command timeout occurs

This appears to have changed in 8.0.11; a timeout exception has now become Fatal error encountered during command execution (inner exception Fatal error encountered attempting to read the resultset), which closes the connection: dd0b53a#diff-997601572c07dd2ca5e054c35564cf2eL84

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 SELECT SLEEP(10); with MySqlCommand.CommandTimeout = 1:

MySql.Data 6.9.11

Afterwards, MySqlConnection.State ConnectionState.Open.

MySql.Data 6.10.4 / 8.0.11

Afterwards, MySqlConnection.State ConnectionState.Closed.

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

Btw can we get our old TimeoutException back?

MySqlConnector (this library) has never thrown a TimeoutException.

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/.

Timeout In Io Operation Mysql Vb.net

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Comments are closed.