Bug #41896 Reading from the stream has failed Exception in MySQL Connector 5.0.8.1
Submitted: 6 Jan 2009 14:50 Modified: 12 Mar 2009 13:28
Reporter: james atherton Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.0.8.1 OS:Windows
Assigned to: Assigned Account CPU Architecture:Any
Tags: Connection, failed, MySqlClient, MySqlException, read, Reading, stream, transport, unable

[6 Jan 2009 14:50] james atherton
Description:
RunSelect -
Exception Message:
   Reading from the stream has failed.
Exception Stack Trace: 
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   at MySql.Data.MySqlClient.MySqlStream.OpenPacket()
   at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
   at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
   at DatabaseFunctions.RunSelect(String query) in c:\Program Files\Clickstream Technologies\Code\CWS\DSAdmin\DatabaseFunctions.cs:line 2569 
Query: SELECT MAX(accountid) + 1 FROM accounts;

We are running a C# web application on IIS 6.0, .Net Framework 2.0 on Win 2003, using Server version: 5.0.45-community-nt-log MySQL Community Edition (GPL).

How to repeat:
We have our application running and for the first few hours it will be fine, if we leave it over night and call the function which runs our SELECT statement against the DB, it will fail with the exception thrown above.
We can then try again and the function call fails, but it is the next query which fails; an INSERT. These use two different connection objects. 
If we run it the third time both queries run fine against the DB and the function call returns true.
It will then run fine as long as we are using it.
then leave it overnight and the problem emerges again for the first call on each connection object.

Our run Select code looks like this:

DataSet RunSelect(string query){
        try
        {
            try{ readconnection.Open(); }catch{}
            MySqlDataAdapter adap = new MySqlDataAdapter();
            adap.SelectCommand = new MySqlCommand(query, readconnection);
            adap.Fill(ds);
        }
        catch (Exception ex)
        {
            ds = null;
        }
        finally
        {
            readconnection.Close();
        }
        return ds;
}
[12 Feb 2009 13:28] Tonci Grgin
Hi James and thanks for your report.

I'm convinced I saw exactly the same one in BugsDB, will have to look.

Now I have two things for you:
  o c/NET 5.0.8 is rather old version and I don't think there will be any bug fixes for it. So please try c/NET 5.2 and inform me of result.
  o Attach compact but complete test case I can use to reproduce the problem. Test case should fail on your boxes always, even if it takes several hours for first failure to surface.
[13 Mar 2009 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".