Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kalyanov <kalyanov@bars.group>2019-04-30 16:11:33 +0300
committerMarek Safar <marek.safar@gmail.com>2019-06-21 12:27:59 +0300
commit480f636808944b8785a6365a107437109201e523 (patch)
tree62702027a8509767684da1e24ae0ff84b86fbe57 /mcs/class/System.Transactions
parenta8b1b2ed20c8c864ff3452f2c5ac1749029b9b6f (diff)
TransactionScope now actually uses IsolationLevel that was specified in TransactionOptions
Previously, using TransactionScope would always produce transactions that use serializable isolation level even when user specified another level (like ReadCommited). fixes #13945
Diffstat (limited to 'mcs/class/System.Transactions')
-rw-r--r--mcs/class/System.Transactions/System.Transactions/CommittableTransaction.cs2
-rw-r--r--mcs/class/System.Transactions/System.Transactions/DependentTransaction.cs1
-rw-r--r--mcs/class/System.Transactions/System.Transactions/SubordinateTransaction.cs1
-rw-r--r--mcs/class/System.Transactions/System.Transactions/Transaction.cs4
-rw-r--r--mcs/class/System.Transactions/System.Transactions/TransactionScope.cs10
-rw-r--r--mcs/class/System.Transactions/Test/TransactionScopeTest.cs20
6 files changed, 31 insertions, 7 deletions
diff --git a/mcs/class/System.Transactions/System.Transactions/CommittableTransaction.cs b/mcs/class/System.Transactions/System.Transactions/CommittableTransaction.cs
index f98f6fa6e12..8c91d356246 100644
--- a/mcs/class/System.Transactions/System.Transactions/CommittableTransaction.cs
+++ b/mcs/class/System.Transactions/System.Transactions/CommittableTransaction.cs
@@ -31,12 +31,14 @@ namespace System.Transactions
}
public CommittableTransaction (TimeSpan timeout)
+ : base (IsolationLevel.Serializable)
{
options = new TransactionOptions ();
options.Timeout = timeout;
}
public CommittableTransaction (TransactionOptions options)
+ : base (options.IsolationLevel)
{
this.options = options;
}
diff --git a/mcs/class/System.Transactions/System.Transactions/DependentTransaction.cs b/mcs/class/System.Transactions/System.Transactions/DependentTransaction.cs
index 6443dbc35f5..7f2a551c613 100644
--- a/mcs/class/System.Transactions/System.Transactions/DependentTransaction.cs
+++ b/mcs/class/System.Transactions/System.Transactions/DependentTransaction.cs
@@ -21,6 +21,7 @@ namespace System.Transactions
internal DependentTransaction (Transaction parent,
DependentCloneOption option)
+ : base(parent.IsolationLevel)
{
// this.parent = parent;
// this.option = option;
diff --git a/mcs/class/System.Transactions/System.Transactions/SubordinateTransaction.cs b/mcs/class/System.Transactions/System.Transactions/SubordinateTransaction.cs
index efb1c4007a3..cdb7cdcf98f 100644
--- a/mcs/class/System.Transactions/System.Transactions/SubordinateTransaction.cs
+++ b/mcs/class/System.Transactions/System.Transactions/SubordinateTransaction.cs
@@ -16,6 +16,7 @@ namespace System.Transactions
{
public SubordinateTransaction (IsolationLevel isoLevel,
ISimpleTransactionSuperior superior)
+ : base (isoLevel)
{
throw new NotImplementedException ();
}
diff --git a/mcs/class/System.Transactions/System.Transactions/Transaction.cs b/mcs/class/System.Transactions/System.Transactions/Transaction.cs
index 33422d15f1e..e1de05591ce 100644
--- a/mcs/class/System.Transactions/System.Transactions/Transaction.cs
+++ b/mcs/class/System.Transactions/System.Transactions/Transaction.cs
@@ -69,10 +69,10 @@ namespace System.Transactions
internal IPromotableSinglePhaseNotification Pspe { get { return pspe; } }
- internal Transaction ()
+ internal Transaction (IsolationLevel isolationLevel)
{
info = new TransactionInformation ();
- level = IsolationLevel.Serializable;
+ level = isolationLevel;
}
internal Transaction (Transaction other)
diff --git a/mcs/class/System.Transactions/System.Transactions/TransactionScope.cs b/mcs/class/System.Transactions/System.Transactions/TransactionScope.cs
index 874ddde0d88..503a4b6b9d9 100644
--- a/mcs/class/System.Transactions/System.Transactions/TransactionScope.cs
+++ b/mcs/class/System.Transactions/System.Transactions/TransactionScope.cs
@@ -138,14 +138,14 @@ namespace System.Transactions
oldTransaction = Transaction.CurrentInternal;
- Transaction.CurrentInternal = transaction = InitTransaction (tx, scopeOption);
+ Transaction.CurrentInternal = transaction = InitTransaction (tx, scopeOption, options);
if (transaction != null)
transaction.InitScope (this);
if (parentScope != null)
parentScope.nested ++;
}
- Transaction InitTransaction (Transaction tx, TransactionScopeOption scopeOption)
+ Transaction InitTransaction (Transaction tx, TransactionScopeOption scopeOption, TransactionOptions options)
{
if (tx != null)
return tx;
@@ -159,7 +159,7 @@ namespace System.Transactions
if (scopeOption == TransactionScopeOption.Required) {
if (Transaction.CurrentInternal == null) {
isRoot = true;
- return new Transaction ();
+ return new Transaction (options.IsolationLevel);
}
parentScope = Transaction.CurrentInternal.Scope;
@@ -170,8 +170,8 @@ namespace System.Transactions
if (Transaction.CurrentInternal != null)
parentScope = Transaction.CurrentInternal.Scope;
isRoot = true;
- return new Transaction ();
- }
+ return new Transaction (options.IsolationLevel);
+ }
public void Complete ()
{
diff --git a/mcs/class/System.Transactions/Test/TransactionScopeTest.cs b/mcs/class/System.Transactions/Test/TransactionScopeTest.cs
index a474c995e63..a741fcf4775 100644
--- a/mcs/class/System.Transactions/Test/TransactionScopeTest.cs
+++ b/mcs/class/System.Transactions/Test/TransactionScopeTest.cs
@@ -1094,6 +1094,26 @@ namespace MonoTests.System.Transactions
}
#endregion
+
+ [Test]
+ public void DefaultIsolationLevel()
+ {
+ using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required))
+ {
+ Assert.AreEqual(IsolationLevel.Serializable, Transaction.Current.IsolationLevel);
+ }
+ }
+
+ [Test]
+ public void ExplicitIsolationLevel()
+ {
+ TransactionOptions transactionOptions = new TransactionOptions();
+ transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
+ using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
+ {
+ Assert.AreEqual(IsolationLevel.ReadCommitted, Transaction.Current.IsolationLevel);
+ }
+ }
}
}