Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Transactionscopes and Distributed Transactions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Roy Jacobs  
View profile  
 More options Oct 19 2012, 8:21 am
From: Roy Jacobs <roy.jac...@gmail.com>
Date: Fri, 19 Oct 2012 05:21:39 -0700 (PDT)
Local: Fri, Oct 19 2012 8:21 am
Subject: Transactionscopes and Distributed Transactions

Hi all,

I see quite a few bugs on JIRA relating to the same topic:
https://nhibernate.jira.com/secure/IssueNavigator.jspa?reset=true&jql...

They're all about the fact that SQL errors cause a session's SqlConnection
to be closed from a different thread than the thread that opened it
(through the AdoNetDistributedTransacionFactory). We've been running into
this issue for quite some time now as well. We store NServiceBus saga's
using NHibernate and occasionally we may get a deadlock. Normally this
would not be a huge problem (just retry the message), but once this
deadlock occurs, we get, for a minute or 2, a log full of errors like "New
request is not allowed to start because it should come with valid
transaction descriptor" and "Distributed transaction completed. Either
enlist this session in a new transaction or the NULL transaction.".

Now, this is something we'd like to have fixed, or fix ourselves. Is anyone
actively looking at this, right now? Or willing to share some
suggestions/findings?

Roy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Oskar Berggren  
View profile  
 More options Oct 19 2012, 8:32 am
From: Oskar Berggren <oskar.bergg...@gmail.com>
Date: Fri, 19 Oct 2012 14:31:55 +0200
Local: Fri, Oct 19 2012 8:31 am
Subject: Re: [nhibernate-development] Transactionscopes and Distributed Transactions

I started to look at all those issues in unison a few weeks back (that's
when a unified them under the TransactionScope label) and I have a few
ideas plus some things that needs further thought. Currently, I think that
some of those issues are "simple" bugs that should be fixed, while other
issues might in fact be unsolvable with the approach that NH currently use.

Eventually I decided that I need to finish and merge the .Net 4 changes
first, before I shift focus. This should be really close now.

/Oskar

2012/10/19 Roy Jacobs <roy.jac...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Jacobs  
View profile  
 More options Oct 19 2012, 8:39 am
From: Roy Jacobs <roy.jac...@gmail.com>
Date: Fri, 19 Oct 2012 05:39:26 -0700 (PDT)
Local: Fri, Oct 19 2012 8:39 am
Subject: Re: [nhibernate-development] Transactionscopes and Distributed Transactions

Ah, okay. Good to hear! One of the workarounds I've read is to use the
regular non-distributed factory because the underlying SqlConnection will
enlist anyway, but that it may cause problems with second level caching.
Are there alternative workarounds to consider for now?

Roy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johannes Gustafsson  
View profile  
 More options Oct 19 2012, 9:34 am
From: Johannes Gustafsson <johanne...@gmail.com>
Date: Fri, 19 Oct 2012 15:34:27 +0200
Local: Fri, Oct 19 2012 9:34 am
Subject: Re: [nhibernate-development] Transactionscopes and Distributed Transactions

+1

We've had the same problems for a long time but I never considered that it
could be because of a bug in NH :-).

2012/10/19 Roy Jacobs <roy.jac...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yngve Nilsen  
View profile  
 More options Apr 30, 5:47 am
From: Yngve Nilsen <yngve.nil...@gmail.com>
Date: Tue, 30 Apr 2013 02:47:21 -0700 (PDT)
Local: Tues, Apr 30 2013 5:47 am
Subject: Re: Transactionscopes and Distributed Transactions

Exactly the same problem here when running NHibernate in NServiceBus hosted
services. In our case it doesn't have to be a deadlock, just a general
failure within the transaction. It seems to be related to the fact that the
SQL ConnectionPool and DTC have some issues with multithreading... Would be
awesome to see a fix for this in NHibernate, since I don't think the
underlying MSDTC or SqlConnectionPool is going to be changed anytime soon.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johannes Gustafsson  
View profile  
 More options Apr 30, 8:34 am
From: Johannes Gustafsson <johanne...@gmail.com>
Date: Tue, 30 Apr 2013 14:34:08 +0200
Local: Tues, Apr 30 2013 8:34 am
Subject: Re: [nhibernate-development] Re: Transactionscopes and Distributed Transactions

I have discovered that if NH throws certain exceptions and you after that
explicitly rolls back the NH transaction (like NSB does), then it will
consistently corrupt the connection pool. Removing the explicit rollback
makes the problem go away, at least in this specific scenario.

Example

using (create TxScope)
using (open session)
using (begin NH.Trans)

try {
session.QueryOver()...SingleOrDefault() // results return 2 rows which
makes NH throw

}

catch (Exception) {
  nhtx.Rollback(); // Throws with message: ROLLBACK without corresponding
BEGIN
  // Connection pool is now corrupt

}

2013/4/30 Yngve Nilsen <yngve.nil...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ramon Smits  
View profile  
 More options May 1, 4:24 am
From: Ramon Smits <ramon.sm...@gmail.com>
Date: Wed, 1 May 2013 10:24:37 +0200
Local: Wed, May 1 2013 4:24 am
Subject: Re: [nhibernate-development] Re: Transactionscopes and Distributed Transactions

Well, AFAIK the NH transaction is automatically rolled back in the dispose
so there is no need to explicitly call Rollback on the nhibernate
transaction but it should not result in e exceptions.

Just looking at the NSB code at
https://github.com/NServiceBus/NServiceBus/blob/master/src/nhibernate...

var session = CurrentSessionContext.Unbind(SessionFactory);

using (session)
using (session.Transaction)
{
if (!session.Transaction.IsActive)
return;

if (ex != null)
session.Transaction.Rollback();
else
session.Transaction.Commit();

}

They perform an explicit rollback as you mentioned.

Are you maybe also using NHibernate within you own message handlers or
saga's?

-- Ramon

On Tue, Apr 30, 2013 at 2:34 PM, Johannes Gustafsson
<johanne...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johannes Gustafsson  
View profile  
 More options May 2, 5:00 am
From: Johannes Gustafsson <johanne...@gmail.com>
Date: Thu, 2 May 2013 11:00:53 +0200
Local: Thurs, May 2 2013 5:00 am
Subject: Re: [nhibernate-development] Re: Transactionscopes and Distributed Transactions

Yes, it seems to only show up when using multiple NH sessions.

I managed to track it a bit further. See here: http://pastebin.com/dKyu6YN9

In the code above I use 2 NH transactions. When I get an exception from NH,
I first try to rollback the first transaction. This succeeds. It seems
though that NH also rolls back the second TX but it doesn't update the
transaction object immediately (probably because it is done in a background
thread). If, howerver, I insert a thread.sleep() after tx #1 rollback, then
the IsActive property on Tx #2 will return false and the code will work as
expected.

So the best workaround should be to simply remove the rollback I suppose.

2013/5/1 Ramon Smits <ramon.sm...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »