Bug #89159 | ResetReader: MySqlDataReader cannot outlive parent MySqlCommand since 6.10 | ||
---|---|---|---|
Submitted: | 9 Jan 2018 12:41 | Modified: | 7 Feb 2020 16:07 |
Reporter: | Timo van Zijll Langhout | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 6.10, 8.0.18 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | MySqlDataReader MySqlCommand ResetReader Dispose |
[9 Jan 2018 12:41]
Timo van Zijll Langhout
[10 Jan 2018 5:13]
Bradley Grainger
This bug was also reported on Stack Overflow here: https://stackoverflow.com/q/47779128
[25 Jan 2018 7:34]
Chiranjeevi Battula
Hello Timo van, Thank you for the bug report. Verified based on internal discussion with dev's. Thanks, Chiranjeevi.
[15 Mar 2018 10:00]
Frédéric Delaporte
This bug further affects following scenario: - Open a command, do stuff with it but do not dispose of it yet. - Open another command and open a reader from it. - Dispose of the first command. This result in the first command closing the reader of the second command! Although the root cause is the same, it looks worth a dedicated bug report. Concrete case where this was discovered: polymorphic query with NHibernate returned as an Enumerable with deferred execution of reads on DataReader. Such a query results in as many commands as there are implementations of the queried entity, each command opening a reader with a safeguard in NHibernate for databases not supporting multiple opened reader ensuring previously opened reader are read into memory and closed prior to the new reader opening. But the command of the reader transfered into memory is not disposed of at that moment, but only a bit later, while another reader has already been opened.
[15 Mar 2018 10:12]
Frédéric Delaporte
Previous comment now reported as #90086
[14 Aug 2018 20:52]
Anatoliy Schmoukler
I would say, for me(us) this is more than S3 (Non-critical). When company is actively seeking support for MySql and already has abstraction layer that supports Sql Server and Oracle, this becomes a show stopper. A code that is DB-Agnostic and has supported Oracle.DataAccess/Oracle.ManagedDataAccess/SqlClient/OleDb with no issues: Dim conn As IDbConnection = NativeConnection.GetConnection(connInfo) Using cmd As IDbCommand = NativeCommand.GetCommandObject(conn) ' +++ Do more stuff to connection here Dim reader As IDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection) ' +++ Do more stuff to connection here Return reader End Using can't support MySqlClient because in MySqlCommand.Dispose() MySqlReader being closed. Other providers call Dispose() in Close(). In fact, CommandBehavior.CloseConnection should be the indicator that MySqlReader should close the connection and MySqlcommand should just fade away gracefully. I believe, this bug should be pushed as higher priority. I think, MySql Devs should disassemble major providers from Microsoft and Oracle and follow the established pattern. We want to pay MySql royalties but we don't want to spend $$ to code for it separately. We have huge system and a lot of SQL. This is huge for us and any company that has data layer that supports multiple DB Engines. Thanks
[14 Aug 2018 21:19]
MySQL Verification Team
Changing severity to serious, notice that severity is defined when reporter filed the bug.
[14 Aug 2018 21:27]
Anatoliy Schmoukler
@Miguel Solorzano I appreciate you expediting this and I understood from the beginning that originator set the priority. Thank you
[21 Aug 2018 21:44]
Bradley Grainger
This has been reported as a bug against Dapper (since it uses the command disposal order described in the OP): https://github.com/StackExchange/Dapper/issues/1101 However, the problem is not really in Dapper; it's triggered by this same underlying issue.
[21 May 2019 12:25]
First LNAME
I'd be interested to know if there are any plans to fix this.
[22 Oct 2019 11:20]
MySQL Verification Team
Bug #97242 marked as duplicate of this one.
[7 Feb 2020 16:07]
Christine Cole
Posted by developer: Fixed as of the upcoming MySQL Connector/NET 8.0.20 release, and here's the proposed changelog entry from the documentation team: Access to the MySqlDataReader object was restricted when the parent MySqlCommand object was closed. This fix modifies MySqlCommand.Dispose() to no longer call the ResetReader method. Thank you for the bug report.