Bug #89632 MySql.Data.MySqlClient.MySqlConnection.set_Reader(MySqlDataReader value) 6.9.11
Submitted: 12 Feb 2018 20:07 Modified: 2 May 2019 12:20
Reporter: Jo kjhjkh Email Updates:
Status: Can't repeat Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.11 OS:Any
Assigned to: CPU Architecture:Any

[12 Feb 2018 20:07] Jo kjhjkh
We updated our library from 6.9.10 to 6.9.11 and now sometime we have this issue

Here is the stack :

System.NullReferenceException: Object reference not set to an instance of an object.
at MySql.Data.MySqlClient.MySqlConnection.set_Reader(MySqlDataReader value): 
at MySql.Data.MySqlClient.MySqlDataReader.Close(): 
at MySql.Data.MySqlClient.MySqlDataReader.Dispose(Boolean disposing): 
at MySql.Data.MySqlClient.MySqlDataReader.Finalize(): 

We have around 10 000 clients using the connector and we got around 10 reports/every day since the update.

How to repeat:

Suggested fix:
A change between 6.9.10 and 6.9.11.
[12 Feb 2018 20:15] Jo kjhjkh

Attachment: img.png (image/png, text), 29.93 KiB.

[13 Feb 2018 12:01] Chiranjeevi Battula
Hello !!,

Thank you for the bug report.
Could you please provide repeatable steps (exact steps/sample project, MySQl version, full stack trace etc. - please make it as private if you prefer) to confirm this issue at our end?

[13 Feb 2018 13:33] Jo kjhjkh
Could you please provide repeatable steps (exact steps/sample project, MySQl version, full stack trace etc. - please make it as private if you prefer) to confirm this issue at our end?

It happen randomly after a while with the datareader

I think it's due to this fix in 6.9.11

Instances of the DataReader class did not close connections implicitly as expected when CommandBehavior was set to CloseConnection. This fix ensures that the connection is closed properly when the DataReader object no longer exists. (Bug #27277013)

Here is the connection that I use

        public MySQL(string sServer, uint sPort, string sDatabase, string sUsername, string sPassword)
            var builder = new MySqlConnectionStringBuilder
                Server = sServer,
                Port = sPort,
                UserID = sUsername,
                Password = sPassword,
                Database = sDatabase,
                CharacterSet = "utf8",
                AllowZeroDateTime = true,
                ConvertZeroDateTime = true,
                AllowUserVariables = true,
                MaximumPoolSize = 1024

            connection.ConnectionString = builder.GetConnectionString(true);
            command = connection.CreateCommand();

Hope this help,
[14 Feb 2018 12:27] Chiranjeevi Battula
Hello !!,

Thank you for the feedback.
I could not repeat the issue at our end using with Visual Studio 2017, Connector/NET 6.9.11 and 6.10.6 versions.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

[1 Jun 2018 14:41] Gregory Fishbein
We have noticed the same issue with 6.9.11. When a query times out the stream in this line is null on the dispose of the MySqlDataReader:

    public int GetResult(ref int affectedRow, ref long insertedId)
        this.packet = this.stream.ReadPacket();
[1 Jun 2018 15:00] Gregory Fishbein
It looks like it is calling this to flush out the results in the data reader:
            while (this.NextResult())

but the driver underneath is disposed already so it throws this error.

            this.resultSet = this.driver.NextResult(this.Statement.StatementId, false);
[1 Jun 2018 15:01] Gregory Fishbein
our call stack is slightly different, but similar:

 	MySql.Data.dll!MySql.Data.MySqlClient.NativeDriver.GetResult(ref int affectedRow, ref long insertedId) 
 	MySql.Data.dll!MySql.Data.MySqlClient.Driver.NextResult(int statementId, bool force) 
>	MySql.Data.dll!MySql.Data.MySqlClient.MySqlDataReader.NextResult() 
 	MySql.Data.dll!MySql.Data.MySqlClient.MySqlDataReader.Dispose(bool disposing) 
[2 May 2019 11:55] Karl Developer
I am also getting this error with 6.9.11. Unfortunately I can't recreate it as I have no idea where the error is happening as the stack trace gives no hint of where it might be...

[2 May 2019 12:20] Jo kjhjkh
I upgraded to version 6.9.12 and all is working well now.

The issue seems to be only in version 6.9.11.