Bug #69496 Timeout errors on 64-bit windows server 2008 r2
Submitted: 18 Jun 2013 9:20 Modified: 9 Jul 2013 11:22
Reporter: r patel Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.2.3.0 OS:Windows (server 2008 r2)
Assigned to: CPU Architecture:Any

[18 Jun 2013 9:20] r patel
Description:
We recently changed our production windows server hardware/software configuration from [win web server 2008-32bit] to [win web server 2008 r2-64bit].

We are using [mysql-5.0.77-x86_64] on [linux server-centos-5.7-x86_64] and [mysql-5.5.30-x86_64] on [linux server-centos-6.3-x86_64]

We use mysql .net connector 6.2.3.0 to communicate with mysql database server.

Except haradware/os change for windows server, everything is as it is and all our code is compiled for any CPU(x86/x64).

On old 32-bit winserver there were no issues in normal/loaded condition.

Now on new 64-bit win server, in load condition, our apps are generating mysql timout exceptions randomly.

We just changed running mode of our most loaded website in IIS to 32-bit mode on newer 64-bit server, it stopped giving mysql errors.

This situation clearly indicates that there is something going wrong with mysql .net connector on 64-bit os.

Is it becuase mysql .net connector is built for 32-bit architecture (as per the text on download page)? if no then what could be the reason?

How to repeat:
problem happens many times in load condition, may be when size of data is big in select query.

Most times below Exception1 occurs:

Exception1:
System.TimeoutException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   --- End of inner exception stack trace ---
   at MyNetworkStream.HandleOrRethrowException(Exception e)
   at MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns)
   at MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId, Int32 columns)
   at MySql.Data.MySqlClient.Driver.SkipDataRow()
   at MySql.Data.MySqlClient.ResultSet.Close()
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlDataReader.Close()
   at System.Data.Common.DbDataReader.Dispose(Boolean disposing)
   at System.Data.Common.DbDataReader.Dispose()
   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(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
============================================================================
Exception1(a):
System.TimeoutException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   --- End of inner exception stack trace ---
   at MyNetworkStream.HandleOrRethrowException(Exception e)
   at MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.ReadOk(Boolean read)
   at MySql.Data.MySqlClient.Driver.SetDatabase(String dbName)
   at MySql.Data.MySqlClient.MySqlConnection.ChangeDatabase(String databaseName)
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
   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(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

============================================================================
Exception2:
MySql.Data.MySqlClient.MySqlException: Reading from the stream has failed. ---> System.IO.IOException: Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall. ---> System.Net.Sockets.SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at MyNetworkStream.HandleOrRethrowException(Exception e)
   at MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   --- End of inner exception stack trace ---
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns)
   at MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId, Int32 columns)
   at MySql.Data.MySqlClient.Driver.SkipDataRow()
   at MySql.Data.MySqlClient.ResultSet.Close()
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlDataReader.Close()
   at System.Data.Common.DbDataReader.Dispose(Boolean disposing)
   at System.Data.Common.DbDataReader.Dispose()
   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(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
[18 Jun 2013 17:48] Fernando Gonzalez.Sanchez
Hi, Thanks for your report.

Connector/NET is CLR code built for AnyCPU, it should work fine for both 32bit apps and 64 bit apps.

You can check this by running the command
corflags mysql.data.dll

see for more details: http://stackoverflow.com/tags/corflags/info

The installer, on the other hand is a 32bit executable. But thats fine, 64bit or platform agnostic code can be intalled with 32bit installers.

Your problem, however is an interesting issue...

Have  you tried a latest version of Connector/NET (last stable version is 6.6.5)?
[9 Jul 2013 11:20] r patel
Due to some other issue, this problem happened.

Everything worked ok after repairing that issue.

Sorry for suspecting MySQL .net connector for that but behavior was such that we suspected it.
[9 Jul 2013 11:22] r patel
It was not a problem of MySQL .Net connector.