Connection unexpectedly terminated
I have a very simple SQL query statement but it needs to be run many times. I get following error randomly, maybe once per one hundred times.
Following thread http://bugs.mysql.com/bug.php?id=6688 mentioned that Since the bug seems to be strongly connected to some timeout, I've tried to manipulate several server variables which are related to timeout settings. I found out that if the value of the variable net_write_timeout is increased to 3600 (previously 60) the error does not occur!
In this thread http://bugs.mysql.com/bug.php?id=45978
it is talked about how to set the net_write_timeout
[Test] public void Bug45978() { MySqlCommand command = OpenConnectionAndCreateCommand(); command.CommandText = "SET net_write_timeout = 1"; command.ExecuteNonQuery(); command.CommandText = "SELECT BlaBla FROM bigtable LIMIT 100000"; using (MySqlDataReader reader = command.ExecuteReader()) { Thread.Sleep(2000); // after this several cycles of DataReader.Read() are executed // normally and then the problem, described above, occurs while (reader.Read()) { object o = reader[0]; } } }
In the last a couple of days website running, I got the above error happened for 664 times. I will set the net_write_timeout value and see whether the condition gets better.
Comments
Post a Comment