试图读取过去的MySQL流错误结束 [英] Attempted to read past end of the stream error in MySQL

查看:9949
本文介绍了试图读取过去的MySQL流错误结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与MySQL的,我有以下错误的问题。

I'm running into a problem with MySQL where I have the following 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.

当我有这个运行在一夜之间出现此错误。它很少发生,所以很难追查为什么发生。我使用.NET 3.5,MySQLConnector 6.2.4.0。

This error occurs when I have this running overnight. And it happens infrequently, so it is hard to track down WHY it's happening. I am using .NET 3.5 with MySQLConnector 6.2.4.0.

我使用下面的code运行它。

I am running it using the following code.

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

正如你所看到的,我不是手动尝试读什么>&LT;我在做一个 adapter.fill(X),所以我在阅读过去的流的末尾没有控制权。

As you can see, I am not manually attempting to read anything >< I'm doing an adapter.fill(x), so I have no control over reading past the end of the stream.

为什么可能会出现这种情况?

Why may be this happening?

请让我知道如果你需要任何更多的细节。

Please let me know if you need any more details.

推荐答案

它看起来像它抛出,超时被超过时。有一个关于它不这样做是一个错误修复,因此,如果他们固定它,现在它的作用。

It looks like it throws that when the timeout is exceeded. There is a bug fix about it NOT doing so, so if they fixed it, now it does.

<一个href="http://www.google.com/url?sa=t&source=web&cd=3&ved=0CCQQFjAC&url=http%3A%2F%2Fdownloads.mysql.com%2Fdocs%2Fconnector-net-en.a4.pdf&ei=isDvTdTDIcregQe-6NSVDw&usg=AFQjCNESAxTm9nhgXMGYvn1KrTnnGp0Wfg&sig2=xcHH3gp9XHm3nVuo-w2r7A" rel="nofollow">http://www.google.com/url?sa=t&source=web&cd=3&ved=0CCQQFjAC&url=http%3A%2F%2Fdownloads.mysql.com%2Fdocs%2Fconnector-net-en.a4.pdf&ei=isDvTdTDIcregQe-6NSVDw&usg=AFQjCNESAxTm9nhgXMGYvn1KrTnnGp0Wfg&sig2=xcHH3gp9XHm3nVuo-w2r7A

的MySQL Connector / NET没有抛出EndOfStreamException已异常。 (错误#53439)

MySQL Connector/NET did not throw an EndOfStreamException exception when net_write_timeout was exceeded. (Bug #53439)

这篇关于试图读取过去的MySQL流错误结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆