This project is read-only.

Throwing an Exception leaks connections

Topics: Troubleshooting
Oct 6, 2011 at 3:50 PM
Edited Oct 6, 2011 at 4:00 PM

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");

                Logger.Debug("Final work for transaction being performed");
                Logger.Debug("Transaction disposed");

I'm using SQL Server 2005, could this be related to

Thanks in advance


Oct 6, 2011 at 5:54 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.