Bug #27289 Transaction is not rolledback when connection close
Submitted: 20 Mar 2007 13:26 Modified: 26 Mar 2007 6:33
Reporter: Luciano C Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.0.5.0 OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[20 Mar 2007 13:26] Luciano C
Description:
When you have pooling enabled in the connection string and then you open a new connection, start transaction, make some command execution, and then disconnect (without rollback or commit) it does not automatic rollback, so, in the next connection open, it already have a transaction opened.
This situation, is not really common one, but, if i forgot to trap an Exception, and i cannot rollback the operation, in the next operation it will be throwing an exception.

How to repeat:
// A little hack

MySqlConnection conn = new MySqlConnection("...");
conn.Open();
MySqlTransaction trans = conn.BeginTransaction();
MySqlCommando cmd = new MySqlCommand("MyExe", conn, trans);
cmd.ExecuteNonQuery();
conn.Close();

conn.Open();
MySqlTransaction trans = conn.BeginTransaction(); // This throw an InvalidOperationException, telling that a transaction context is already opened, and cannot created nested transactions.

Suggested fix:
To rollback the transaction when the connection is closed or disposed.
[22 Mar 2007 13:08] Tonci Grgin
Hi and thanks for your report. I think it's intentional behavior but will consult.
[22 Mar 2007 21:16] 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/22707
[23 Mar 2007 1:35] Luciano C
Yes, maybe it is a common intentional mistake, but, how do i check if it is already a transaction opened? Maybe it is intentional, but i think that is a bug either :)
Thanks
[23 Mar 2007 2:26] Reggie Burnett
Fixed in 5.0.7
[26 Mar 2007 6:33] MC Brown
A note has been added to the 5.0.7 changelog.