Bug #25458 Opening connection hangs
Submitted: 7 Jan 2007 23:33 Modified: 23 Jan 2007 15:30
Reporter: Nick Van Eeckhout Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:5.0.3 connector and 4.0.15 mysql db OS:Microsoft Windows (Win XP SP2)
Assigned to: CPU Architecture:Any

[7 Jan 2007 23:33] Nick Van Eeckhout
Description:
I'm using the TableEditor project in the samples directory.
I'm running Visual Studio 2005 on Windows XP SP2 with .net framework 2.0 and mysql.data provider 5.0.2. I also tried this on another machine with the same basic setup and it didn't work there either.
When creating a connection to a remote database (version: 4.0.15-nt) with a valid user and a valid password, the code hangs when opening the connection. Connecting with an incorrect username/password returns the expected exception.
Debugging the provider leads to the dispose of the datareader > close of the datareader > calling nextresult
Diggin a little deeper takes me to line 757 in datareader.cs in function private long GetResultSet() = long fieldCount = driver.ReadResult(ref affectedRowsTemp, ref lastInsertId);
Taking me to NativeDriver.cs, line 441: stream.OpenPacket();
Taking me to MySqlStream.cs, line 176: int b1 = inStream.ReadByte(); (in function LoadPacket) where it hangs.

How to repeat:
don't know

Suggested fix:
Commenting lines 177-178 in datareader.cs solves the problem.

// we set the nextResultDone var to true inside NextResult when
// it returns false. This allows us to avoid calling NextResult
// here unnecessarily. Calling NextResult here will work but this
// is just an optimization.
if (!nextResultDone)
   while (NextResult()) { }
[8 Jan 2007 19:49] Nick Van Eeckhout
Just tested with the 5.0.3 version and result is the same as in the 5.0.2 version. Code hangs on reading bytes from the buffered stream in the nativeDriver.cs when disposing the datareader upon opening a connection.
[8 Jan 2007 23:40] Nick Van Eeckhout
A little update:
I've done some selects after opening the connection and i get the same behaviour.
In a table with 3 columns there are 2 rows inserted (with the use of the connector, so that works). When retrieving the records through the use of executedataset, the code hangs too.

Running through the code does the following:
the 2 records get retrieved and are stored in the dataset, but after the second row the NextResult function gets called again and here it stops.
further stacktrace: ReadResult > Stream.OpenPacket > LoadPacket > inStream.ReadByte()

I've tried this against a local 5.0.27 mysql db and the error can't be reproduced.
[12 Jan 2007 14:40] Kostas Stroggylos
The bug also seems to exist on Windows platforms (Windows XP SP2 / Windows Server 2000) with MySQL server version 4.0.16-max-nt
[15 Jan 2007 13:29] Tonci Grgin
Hi Nick and thanks for your report. 
Verified as described by reporter with 5.0.3 driver built from sources today against MySQL server 4.0.28BK on Suse 10.0 host. Client is WinXP Pro SP2 with NET FW 2.0

Same test case (TableEditor) works with c/NET 5.0.1.
[16 Jan 2007 19:30] Reggie Burnett
Fixed in 5.0.4
[16 Jan 2007 19:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/18210
[23 Jan 2007 15:30] MC Brown
A note has been added to the 5.0.4 changelog.