From: William L. (JIRA) <nh...@gm...> - 2010-08-10 01:12:02
|
[ http://216.121.112.228/browse/NH-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19627#action_19627 ] William Lai commented on NH-2107: --------------------------------- Our final solution is to close the connection explicitly in our code, i.e. set "connection.release_mode" to "on_close". However, we need to refactor many of our codes in order to do this. We need to add code to close connection in all places where there is db access, even we only want to retrieve but not saving any data. We start using nhibernate from version 1.2.1 and we find that it is easy to implement. But now we need to be more carefully about the design pattern. This solution make our code less clean and more bug prone. > 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 |