首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >执行MySqlDataReader::Read()时超时

执行MySqlDataReader::Read()时超时
EN

Stack Overflow用户
提问于 2014-11-13 20:54:07
回答 1查看 2K关注 0票数 3

在MySqlDataReader对象上调用Read()时,我得到了以下异常。

代码语言:javascript
复制
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个小时,然后最终显示以下异常和堆栈跟踪。

代码语言:javascript
复制
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()

大约在同一时间,相同的错误发生在不同的代码段中,从不同的服务器读取完全不同的表,所以我倾向于认为问题存在于客户端。有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2016-03-29 19:03:17

这里很可能就是这个bug:https://bugs.mysql.com/bug.php?id=75604

如果在您执行命令时Environment.TickCount发生翻转(在24.9天的服务器正常运行时间之后),那么连接器将抛出与您看到的完全相同的异常。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26909360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档