From: Sam R. (JIRA) <nh...@gm...> - 2010-08-09 14:11:08
|
[ http://216.121.112.228/browse/NH-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19624#action_19624 ] Sam Ritchie commented on NH-2107: --------------------------------- Sorry Fabio, are you saying that explicitly using an NH transaction within a TransactionScope should work properly? This is not normal usage of a TransactionScope - most developers would expect the resource managers to participate in the ambient transaction without further intervention. eg I regard this as idiomatic usage of a TransactionScope: using (var transaction = new TransactionScope()) { SomeObj obj = session.Get<SomeObj>(id); // I expect this line to start a local transaction on SQL Server 2005 messageQueue.Send(obj, MessageQueueTransactionType.Automatic); // I expect this line to escalate the transaction to MSDTC transaction.Complete(); // commit the transaction on SQL & MSMQ } // exception will roll back the transaction on SQL & MSMQ If I was using a straight SqlConnection/SqlCommand instead of NH I would not create an SqlTransaction at all, the TransactionScope would handle it for me. I hope this explains where I'm coming from. > Database connection is not closed after rollback in TransactionScope > -------------------------------------------------------------------- > > Key: NH-2107 > URL: http://216.121.112.228/browse/NH-2107 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 2.1.2.GA > Reporter: William Lai > Attachments: ProgramToReproduce.zip > > > .Net Framework Version: 3.5 > Database: SQL Server 2005 > We have just migrated from version 1.2.1 to 2.1.2GA since we need to integrate multiple layer of components using the TransactionScope. After some testing, we find that the database connection increases continuously after every transaction rollback. At the end, all the connections in the connection pool are used up. The problem does not occur in commit case. > Here is the testing code: > ISession session = null; > Test test = null; // Database object > using (TransactionScope scope = new TransactionScope()) > { > session = NHibernateHelper.OpenSession(); > Test test2 = new Test(); > test2.Name = DateTime.Now.ToString(); > session.SaveOrUpdate(test2); > //scope.Complete(); > } > After running the above case, a new connection will be used in SQL Server. The connection will not free up in SQL Server until we close our application. > Any advise for the problem? Thanks in advance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |