Skip to content

Commit 12676c1

Browse files
committed
Fix NH-3572: Avoid calling AfterTransactionCompletion twice when a distributed transaction is rolled back.
1 parent 0df5b9d commit 12676c1

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void Rollback()
6565
{
6666
}
6767
Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled);
68-
Assert.AreEqual(2, interceptor.afterTransactionCompletionCalled);
68+
Assert.AreEqual(1, interceptor.afterTransactionCompletionCalled);
6969
}
7070

7171
[Test]
@@ -109,16 +109,13 @@ public void OneTransactionScopesInsideOneSession()
109109
}
110110

111111

112-
[Description("NH2128")]
112+
[Description("NH2128, NH3572")]
113113
[Theory]
114114
public void ShouldNotifyAfterDistributedTransaction(bool doCommit)
115115
{
116116
// Note: For distributed transaction, calling Close() on the session isn't
117117
// supported, so we don't need to test that scenario.
118118

119-
if (!doCommit)
120-
Assert.Ignore("Rollback on distributed transaction doubles the number of calls to AfterTransactionCompletion - see NH-3572.");
121-
122119
var interceptor = new RecordingInterceptor();
123120
ISession s1 = null;
124121
ISession s2 = null;

src/NHibernate/Transaction/AdoNetWithDistributedTransactionFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ void IEnlistmentNotification.Rollback(Enlistment enlistment)
147147
{
148148
using (new SessionIdLoggingContext(sessionImplementor.SessionId))
149149
{
150-
sessionImplementor.AfterTransactionCompletion(false, null);
151150
logger.Debug("rolled back DTC transaction");
151+
// Currently AfterTransactionCompletion is called by the handler for the TransactionCompleted event.
152+
//sessionImplementor.AfterTransactionCompletion(false, null);
152153
enlistment.Done();
153154
IsInActiveTransaction = false;
154155
}

0 commit comments

Comments
 (0)