AdoNetWithDistrubtedTransactionFactory unable to close connection during TransactionCompleted event

Description

Hello,

The AdoNetWithDistrubtedTransactionFactory has an event hooked up to the TransactionCompleted of an ambient transaction.

The very end of that delegate has the code:

------
If Dispose was called on the Session, then transactionContext.ShouldCloseSessionOnDistributedTransactionCompleted will be true.

The call to 'CloseSessionFromDistributedTransaction()' will wind itself around to this method:

Since session.TransactionContext is not null, the attempt disconnect the session will fail because the transaction is still 'active'

I would say that the delegate should be changed to read like this:

Basically changing it to null out the session.TransactionContext before the attempt is made to close the session.

Thanks for reading,
Mark

Environment

None

Attachments

6

Activity

Show:

Chandra V August 2, 2016 at 4:16 PM

Hi Alexander - Thank you very much for providing the details about the fix that is applied to resolve the issue. It helps!

Thanks
Chandra

Alex Zaytsev August 2, 2016 at 2:30 AM

The proposed fix is simply incorrect because it just hides the problem, instead of fixing it. The appropriate fix (to set `IsInActiveTransaction` to `false`) is applied by the commit: https://github.com/nhibernate/nhibernate-core/commit/676921b5

Chandra V August 2, 2016 at 12:38 AM

Hi Alexander - Thanks for confirming. However, I am still unable to locate the fix in 3.0.0.4000 version of NHibernate assembly. Based on what suggested as 'potential fix' by Mark, I assumed the fix should be shown as below. However, In the Nhibernate assembly, the Session.TransactionContext call is made at the end of the block(included the snapshot for your reference). Could you please help me understand it? Thank you!

session.AfterTransactionCompletion(wasSuccessful, null);
session.TransactionContext = null;
if (transactionContext.ShouldCloseSessionOnDistributedTransactionCompleted)
{
session.CloseSessionFromDistributedTransaction();
}

Alex Zaytsev August 1, 2016 at 11:33 PM

It's all across since the 3.0.0 GA

Chandra V August 1, 2016 at 11:07 PM

Hi Alexander - Could you please confirm which version of Nhibernate assembly includes this fix as stated in your comment? I could not find the fix info using the commit tag 676921b5 / trunk@5285.

I really appreciate your help!

Thanks in advance!
Chandra

Duplicate

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created December 30, 2009 at 8:47 AM
Updated August 2, 2016 at 4:16 PM
Resolved June 9, 2016 at 4:36 AM
Who's Looking?