List:MySQL and .NET« Previous MessageNext Message »
From:Reggie Burnett Date:October 20 2004 4:38pm
Subject:Re: Hung datareader
View as plain text  
Is this on a database that exists or doesn't exist?  Here is the NUnit 
test case I just wrote to check this.  Works fine with current code 
against 4.1.6 and latest 5.0 code.

        [Test()]
        public void HungDataReader()
        {
            MySqlCommand cmd = new MySqlCommand("USE Test; SHOW TABLES", 
conn);
            MySqlDataReader reader = null;
            try
            {
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    string s = reader.GetString(0);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail( ex.Message );
            }
            finally
            {
                if (reader != null) reader.Close();
            }
        }

THOULON Pierre-Yves wrote:

>	I get a hung datareader when I try to close it. This is on WinServer 2003, with MySQL
> v4.1.5 gamma, with MyConnector/.NET bits from Oct 5th. It used to work with 1.0 beta 1 but
> I had to get more recent bits to overcome the NULL column problem. Note that I haven't
> tried more recent bits, having problems compiling them (see previous posting, sorry...).
>	 
>	Sequence of events:
>	 
>	- Prepare everything for the connection
>	- Send out several commands that work
>	- then (sqlCmd is a MySqlCommand object):
>	 
>	sqlCmd->CommandText = "use mydatabase; show tables;";
>	MySqlDataReader* rdr = sqlCmd->ExecuteReader();
>	while (rdr->Read()) {
>	    String* tblname = rdr->GetString(0);
>	    // do something with tblname
>	}
>	rdr->Close(); //hangs
>	 
>	 
>	Hangs on line (in PacketReader.cs/OpenReader(); this line just never returns; no
> exception, no nothing):
>	packetLength = stream.ReadByte() +  (stream.ReadByte() << 8) +
> (stream.ReadByte() << 16);
>
>	Dump of the call stack at hang time (when pausing the debugger)
>
>	*	00000000() 
>	*	system.dll!System.Net.Sockets.Socket.Receive(byte[] buffer = {Length=4096}, int
> offset = 0, int size = 4096, System.Net.Sockets.SocketFlags socketFlags = None) + 0x14e
> bytes  
>	*	system.dll!System.Net.Sockets.NetworkStream.Read(byte[] buffer = {Length=4096}, int
> offset = 0, int size = 4096) + 0x150 bytes  
>	*	mscorlib.dll!System.IO.BufferedStream.ReadByte() + 0x87 bytes  
>	*	mysql.data.dll!MySql.Data.MySqlClient.PacketReader.OpenPacket() Line 83 + 0xe bytes
> 
>	*	mysql.data.dll!MySql.Data.MySqlClient.NativeDriver.ReadResult(ulong affectedRows =
> 0, long lastInsertId = 0, MySql.Data.MySqlClient.ServerStatusFlags serverStatus = 10, int
> warningCount = 0, string serverMessage = null) Line 385 
>	*	mysql.data.dll!MySql.Data.MySqlClient.CommandResult.ReadNextResult(bool isFirst =
> false) Line 117 + 0x2c bytes 
>	*	mysql.data.dll!MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySql.Data.MySqlClient.MySqlDataReader
> reader = <undefined value>) Line 300 + 0x13 bytes 
>	*	mysql.data.dll!MySql.Data.MySqlClient.MySqlCommand.Consume() Line 273 + 0xa bytes 
>	*	mysql.data.dll!MySql.Data.MySqlClient.MySqlDataReader.Close() Line 128
>		
>
>	After a bit more investigation, I was able to circumvent the problem by splitting the
> command line into two separate commands: "use mydatabase" with a
> sqlCmd->ExecuteNonQuery(), followed by a "show tables;" with ExecuteReader().
>	 
>	It used to work on ByteFX 0.76 and on Connector/.NET 1.0 beta , so I'm curious: is it
> illegal to concatenate several command and send a single Execute, or are there other
> precautions to be taken ?
>	 
>	Thanks,
>	Pyt.
>
>
>  
>

-- 
Reggie Burnett, Software Developer
MySQL Inc, http://www.mysql.com

Thread
Hung datareaderTHOULON Pierre-Yves18 Oct
  • Re: Hung datareaderReggie Burnett20 Oct
RE: Hung datareaderTHOULON Pierre-Yves21 Oct
  • Stability for 4.0Jordan Sparks21 Oct
    • Re: Stability for 4.0Barry Zubel21 Oct
      • Re: Stability for 4.0Reggie Burnett21 Oct
        • Re: Stability for 4.0Barry Zubel22 Oct
Re: Stability for 4.0Barry Zubel21 Oct