TransactionScope and MySql => Nested transactions are not supported

722 views
Skip to first unread message

Jacob Madsen

unread,
Nov 20, 2010, 8:40:34 AM11/20/10
to nhusers
Hi all,

I have a customer where the system is running on Amazon Web Services.
They already have a running system with NH and MySql. TransactionScope
is not used, since NH transactions is enough to do the job.

The MySql setup is tested, multiple machines and have great uptime.

Now they are trying out RavenDB for some reporting features. They want
to use TransactionScope for transactions.

This is now an issue, since NH or the MySql client throw up with
"Nested transactions are not supported", when BeginTransaction() is
invoked on the ISession object.


Is it a complete no-go with MySql or can we do something to get
TransactionScope working with NH transaction?

I read several times read on this list that NH transaction is needed
for NH internals to work properly, so I don't wont to stop using it.


Cheer!

Jason Dentler

unread,
Nov 20, 2010, 2:19:37 PM11/20/10
to nhu...@googlegroups.com
I'm not a MySQL guy. I'm pretty confident, when done properly, TransactionScope works with MySQL simply because I haven't seen anyone post here that it doesn't. 

using (var ts = new TransactionScope())
{
   // Do some RavenDB work here maybe
   // Open the session & transaction inside the TransactionScope
   using (var session = sessionFactory.OpenSession())
   {
      using (var tx = session.BeginTransaction())
      {
         // Do all your NH / MySQL work here
         tx.Commit();
      }
   }
   // You can also do some RavenDB work here
   // Notice that this is *after* the session has been disposed. 
   ts.Complete();
}




--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.


eti

unread,
Nov 22, 2010, 7:09:19 AM11/22/10
to nhu...@googlegroups.com
Hi,

I guess the problem is that mysql .net connector does not support
distributed transactions. I had a similar problem trying to use
nservicebus with transactional msmq and nhibernate.

I've described my conclusions here
http://www.erata.net/net/nservicebus-with-nhibernate-and-mysql/

Hope it helps
eti

> <mailto:nhu...@googlegroups.com>.


> To unsubscribe from this group, send email to
> nhusers+u...@googlegroups.com

> <mailto:nhusers%2Bunsu...@googlegroups.com>.

Jacob Madsen

unread,
Nov 23, 2010, 8:18:52 AM11/23/10
to nhusers
I can see that you solved the problem.

Too bad the actual feature is not implemented in the official package.

I would really hate going from MySql to MsSql, but it seems like an
option.


On Nov 22, 1:09 pm, eti <etis...@gmail.com> wrote:
> Hi,
>
> I guess the problem is that mysql .net connector does not support
> distributed transactions. I had a similar problem trying to use
> nservicebus with transactional msmq and nhibernate.
>
> I've described my conclusions herehttp://www.erata.net/net/nservicebus-with-nhibernate-and-mysql/
Reply all
Reply to author
Forward
0 new messages