16

MySQLで問題が発生し、次のエラーが発生します。

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.

このエラーは、これを一晩実行しているときに発生します。そして、それはめったに起こらないので、なぜそれが起こっているのかを突き止めるのは難しいです。MySQLConnector6.2.4.0で.NET3.5を使用しています。

次のコードを使用して実行しています。

        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;
    }

ご覧のとおり、私は手動で何かを読み取ろうとはしていません> <実行しているadapter.fill(x)ので、ストリームの終わりを超えて読み取ることを制御できません。

なぜこれが起こっているのでしょうか?

詳細が必要な場合はお知らせください。

4

1 に答える 1

8

タイムアウトを超えるとスローされるようです。そうしないことについてのバグ修正があります、それで彼らがそれを修正したならば、今それはそうします。

Connector-net-en.a4.pdf(MySQLドキュメント)

net_write_timeoutを超えたときに、MySQL Connector/NETがEndOfStreamException例外をスローしませんでした。(バグ#53439)

于 2011-06-08T18:37:15.250 に答える