Intento de leer el final del error de transmisión en MySQL

Tengo un problema con MySQL donde tengo el siguiente error.

MySqlClient.MySqlException: Fatal error encountered during command execution. ---> 
MySql.Data.MySqlClient.MySqlException: Fatal error encountered attempting to read the resultset. ---> 
MySql.Data.MySqlClient.MySqlException: Reading from the stream has failed. ---> 
System.IO.EndOfStreamException: Attempted to read past the end of the stream.

Este error ocurre cuando tengo esto ejecutándose durante la noche. Y sucede con poca frecuencia, por lo que es difícil rastrear POR QUÉ está sucediendo. Estoy usando .NET 3.5 con MySQLConnector 6.2.4.0.

Lo estoy ejecutando con el siguiente código.

        public DataSet Read(String query, List<KeyValuePair<String, object>> parameters)
    {
        MySqlDataAdapter adapter = null;
        DataSet returnVal = null;
        if (query != null && query.Length > 0)
        {
            try
            {
                returnVal = new DataSet();
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                query = SQLHelper.formatSQL(query);
                MySqlCommand command = buildCommand(connection, query, parameters);

                Stopwatch stopwatch = new Stopwatch();

                command.CommandTimeout = 120;
                adapter = new MySqlDataAdapter(command);
                log.Debug(adapter.SelectCommand.CommandText);
                stopwatch.Start();
                adapter.Fill(returnVal);
                stopwatch.Stop();
                if (stopwatch.ElapsedMilliseconds < 150)
                {
                    log.Debug(stopwatch.ElapsedMilliseconds + "ms to run query");
                }
                else
                {
                    StringBuilder sb = new StringBuilder("");
                    if (parameters != null)
                    {
                        foreach (KeyValuePair<String, object> kvp in parameters)
                        {
                            sb.Append(kvp.Key);
                            sb.Append(" = ");
                            if (kvp.Value != null)
                            {
                                sb.Append(kvp.Value.ToString());
                            }
                            else
                            {
                                sb.Append("NULL");
                            }
                            sb.Append(", ");
                        }
                    }
                    log.Warn(stopwatch.ElapsedMilliseconds + "ms to run query: " + adapter.SelectCommand.CommandText + "Values: " + sb.ToString());
                }
            }
            catch (MySqlException msqlex)
            {
                log.Error(msqlex);
                returnVal = null;
                MessageBox.Show(query + "\r\n" + msqlex.ToString());
            }
            finally
            {
            }
        }
        else
        {
            log.Error("Query is empty. Returning null");
        }
        return returnVal;
    }

omo puede ver, no estoy intentando leer nada manualmente> <Estoy haciendo unadapter.fill(x), así que no tengo control sobre la lectura más allá del final de la transmisión.

¿Por qué puede estar sucediendo esto?

Por favor, avíseme si necesita más detalles.

Respuestas a la pregunta(1)

Su respuesta a la pregunta