在MySqlDataReader对象上调用Read()时,我得到了以下异常。
using (MySqlConnection con = new MySqlConnection(myConnectionString))
{
con.Open();
using (MySqlCommand command = con.CreateCommand())
{
command.CommandText = String.Format("SELECT ID FROM MyTable WHERE ID IN ({0})", idList.ToString());
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
int id = Int32.Parse(reader["ID"].ToString());
if (!idHashSet.Contains(id))
{
idHashSet.Add(id);
}
}
}
}程序似乎冻结了大约8个小时,然后最终显示以下异常和堆栈跟踪。
Timeout can be only be set to 'System.Threading.Timeout.Infinite' or a value > 0.
Parameter name: value
System.Net.Sockets.NetworkStream.set_ReadTimeout(Int32 value)
MySql.Data.MySqlClient.TimedStream.StartTimer(IOKind op)
MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
MySql.Data.MySqlClient.MySqlStream.LoadPacket()
MySql.Data.MySqlClient.MySqlStream.ReadPacket()
MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns)
MySql.Data.MySqlClient.ResultSet.NextRow(CommandBehavior behavior)
MySql.Data.MySqlClient.MySqlDataReader.Read()大约在同一时间,相同的错误发生在不同的代码段中,从不同的服务器读取完全不同的表,所以我倾向于认为问题存在于客户端。有什么建议吗?
发布于 2016-03-29 19:03:17
这里很可能就是这个bug:https://bugs.mysql.com/bug.php?id=75604
如果在您执行命令时Environment.TickCount发生翻转(在24.9天的服务器正常运行时间之后),那么连接器将抛出与您看到的完全相同的异常。
https://stackoverflow.com/questions/26909360
复制相似问题