Bug #34448 Connector .Net 5.2.0 with Transactionscope doesn´t use specified IsolationLevel
Submitted: 10 Feb 2008 17:39 Modified: 1 Mar 2008 12:00
Reporter: Thilo Raufeisen
Status: Closed
Category:Connector/Net Severity:S2 (Serious)
Version:5.2.0 OS:Microsoft Windows
Assigned to: Target Version:

[10 Feb 2008 17:39] Thilo Raufeisen
Description:
Connector .Net 5.2.0 with Transactionscope doesn´t use specified IsolationLevel.

expected result:
Connector switches to "ReadCommitted" on connect

actual result:
Connector switches to the default value "Repeatable Read"
mysqld querylog: SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ'

How to repeat:
using System.Transactions;
using MySql.Data.MySqlClient;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            TransactionOptions topts = new TransactionOptions { IsolationLevel =
IsolationLevel.ReadCommitted };
            using (TransactionScope tscope = new
TransactionScope(TransactionScopeOption.Required, topts))
            {
                using (MySqlConnection myconn = new MySqlConnection(@"host=localhost;user
id=root;database=test"))
                {
                    myconn.Open();
                }
            }
        }
    }
}

Suggested fix:
Index: MySqlPromotableTransaction.cs
===================================================================
--- MySqlPromotableTransaction.cs	(revision 1169)
+++ MySqlPromotableTransaction.cs	(working copy)
@@ -44,7 +44,8 @@
 
         void IPromotableSinglePhaseNotification.Initialize()
         {
-            simpleTransaction = connection.BeginTransaction();
+            System.Data.IsolationLevel iso =
(System.Data.IsolationLevel)Enum.Parse(typeof(System.Data.IsolationLevel),
baseTransaction.IsolationLevel.ToString());
+            simpleTransaction = connection.BeginTransaction(iso);
         }
 
         void IPromotableSinglePhaseNotification.Rollback(SinglePhaseEnlistment
singlePhaseEnlistment)
[22 Feb 2008 21:52] 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/42877
[22 Feb 2008 21:54] Reggie Burnett
Fixed in 5.1.6 and 5.2.1
[1 Mar 2008 12:00] MC Brown
A note has been added to the 5.1.6, and 5.2.1 changelogs: 

Attempting to use an isolation level other than the default with a transaction scope
would use the default isolation level.