Reputation: 828
I get the following exception while calling Read() on a MySqlDataReader object.
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);
}
}
}
}
The program seems to freeze for about 8 hours, and then finally spits out the following exception and stack trace.
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()
The same error is occurring at a different section of code around the same time, which reads from a completely different table from a different server, so I am inclined to think that the problem exists on the client side. Any suggestions?
Upvotes: 3
Views: 2652
Reputation: 25676
Could well be this bug here: https://bugs.mysql.com/bug.php?id=75604
If Environment.TickCount
rolls over (after 24.9 days of server uptime) whilst you're executing a command then the connector will throw the exact exception you are seeing.
Upvotes: 2