-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: deadlock with session.flush within transactionscope
PostPosted: Fri Feb 02, 2007 5:18 pm 
Newbie

Joined: Fri Feb 02, 2007 4:59 pm
Posts: 1
Hello,
I have a section of code like this in my application, which works fine in a single threaded environment, but when I run this in multi-threaded environment, or in two different services, it'll encounter a deadlock exception (NHibernate.Util.ADOExceptionReporter - System.Data.SqlClient.SqlException: Transaction (Process ID 55) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.)

I wonder if anyone else experienced this before.

using (TransactionScope scope = new TransactionScope())
{
........ //this part is not needed to create the deadlock

using (ISession session = sessionFactory.OpenSession())
{
Message msg = session.Get(typeof(Message ), ID) as Message;

if (msg == null)
{
msg = new Message();
msg.ID = ID;
msg.UpdateDate = xxxxxx;

session.Save(msg);
}

System.Threading.Thread.Sleep(3000);

session.Flush();
}

scope.complete()
}

Thanks,
- Sam


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 03, 2007 12:30 am 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
This is a System.Transactions issue, right?
if you are using 1.2 beta 3, make sure to specify release_mode = on_close


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.