Bug #47184 Rollback fails with a ArgumentException
Submitted: 8 Sep 2009 1:57 Modified: 16 Sep 2009 20:45
Reporter: Bassam Tabbara Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.2.7 OS:Linux
Assigned to: CPU Architecture:Any

[8 Sep 2009 1:57] Bassam Tabbara
Description:
I'm seeing the following exception thrown on our production servers:

System.ArgumentNullException: Argument cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2<string, MySql.Data.MySqlClient.CharacterSet>.get_Item (string) <0x00170>
at MySql.Data.MySqlClient.CharSetMap.GetCharacterSet (MySql.Data.Common.DBVersion,string) <0x0001a>
at MySql.Data.MySqlClient.NativeDriver.GetFieldMetaData41 () <0x00339>
at MySql.Data.MySqlClient.NativeDriver.GetFieldMetaData () <0x00039>
at MySql.Data.MySqlClient.NativeDriver.ReadColumnMetadata (int) <0x00030>
at MySql.Data.MySqlClient.MySqlDataReader.NextResult () <0x0023c>
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader (System.Data.CommandBehavior) <0x00563>
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader () <0x00012>
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery () <0x0002f>
at MySql.Data.MySqlClient.MySqlTransaction.Rollback () <0x00097>
at MySql.Data.MySqlClient.MySqlConnection.CloseFully () <0x00078>
at MySql.Data.MySqlClient.MySqlConnection.Close () <0x0005a>
at MySql.Data.MySqlClient.MySqlConnection.Dispose (bool) <0x00036>

Its really odd that ReadColumnMetadata is being called on the Rollback code path. Why would Rollback return any result set?

We are running 5.1.37 version of MySql on Debian lenny.

Also I really don't understand what state the connection is left in after this failure. Is the transaction still open? We have connection pooling turned on, will the next use of the connection silently commit the transaction? 

How to repeat:
I don't have a solid repro, but I would appreciate any input regardless.

Suggested fix:
Close the connection and remove the pool on Rollback failures?
[9 Sep 2009 8:08] Tonci Grgin
Hi Bassam and thanks for yet another report.

As with other reports, there is no reproducible test case attached so I'm not able to do anything...
As for stack trace, only a magician could have tell more just by looking at it.

So, what now?
[11 Sep 2009 19:11] Bassam Tabbara
I'm working on getting a repro. Its hard however since it happens under load.

What I wanted to get your opinion on was whether the ROLLBACK command ever returns a result set. The stack trace suggests that it does. Can you offer any guidance here.
[16 Sep 2009 9:49] Tonci Grgin
Bassam, to my opinion, it should at least return "0 rows affected"... You should better check such things in command line client.

What about test case?
[16 Sep 2009 9:51] Tonci Grgin
Maybe adding "logging=true" to your connection string will shed some light onto this?
[16 Sep 2009 20:45] Bassam Tabbara
The root cause of this was that transaction Enlistment was enabled on mono which is really busted. I built with the MONO flag and it seems to have gone away. Closing.
[17 Sep 2009 5:36] Tonci Grgin
Thank you Bassam, I am sure others will benefit from your findings.