When an exception is thrown the TransactionManager cancels the transaction which then bypasses the scope.complete. This includes the OrchardSecurityException ( I had mine in a driver for 'members only')
The scope is disposed, but by not calling the complete the connection is leaked. I've tried moving the complete to outside the if (!_cancelled) and this resolves the problem, however I appreciate this will have unwanted effects. I've only been working on Orchard for a few months, so hoping some of you experts out there have an opinion on the matter
void IDisposable.Dispose() { if (_scope != null) { if (!_cancelled) { Logger.Debug("Marking transaction as complete"); _scope.Complete(); } Logger.Debug("Final work for transaction being performed"); _scope.Dispose(); Logger.Debug("Transaction disposed"); } }
I'm using SQL Server 2005, could this be related to
https://nhibernate.jira.com/browse/NH-2107
Thanks in advance
JEB