From: Sam R. (JIRA) <nh...@gm...> - 2010-08-09 12:34:06
|
[ http://216.121.112.228/browse/NH-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19616#action_19616 ] Sam Ritchie commented on NH-2107: --------------------------------- I'm a bit concerned the 'solution' that appears to be implicitly touted here is "change your design so that you dispose the ISession before calling transaction.Complete()". That's not a solution - it's a workaround. Most of us are no doubt discovering this bug by managing the session lifecycle external to the transactional code, eg via dependency injection. NServiceBus in particular is causing us issues as the transaction lifecycle is also external to user code. To illustrate the conceptual issue I have with this design approach, allow me to inflict terrible ASCII art on you all. This is a sequence diagram showing how you use NHibernate transactions: ISession ITransaction | | | | | | |---->| | | |<----| | | | | | |---->| | | |<----| | | | | | | And this is how it appears you're 'meant' to use a TransactionScope ISession TransactionScope | | | | | | | | | | | | | | | | | | I'm not sure I understand why the different transaction technology requires a complete reversal of the respective lifecycles - this is going to be extraordinarily non-obvious to pretty much everyone who stumbles across it. > 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 |