This project is read-only.

Transaction Exception

Nov 16, 2010 at 10:22 AM


when I use Orchard for a while, sooner or later some exceptions occur regarding the TransactionScope. When I reload the page several times, the exception disappears. 


Line 24:             if (_scope == null) {
Line 25:                 Logger.Debug("Creating transaction on Demand");
Line 26:                 _scope = new TransactionScope(TransactionScopeOption.Required);
Line 27:             }
Line 28:         }

[TransactionAbortedException: The transaction has aborted.]
   System.Transactions.TransactionStateAborted.CreateAbortingClone(InternalTransaction tx) +11
   System.Transactions.DependentTransaction..ctor(IsolationLevel isoLevel, InternalTransaction internalTransaction, Boolean blocking) +112
   System.Transactions.Transaction.DependentClone(DependentCloneOption cloneOption) +143
   System.Transactions.TransactionScope.SetCurrent(Transaction newCurrent) +110
   System.Transactions.TransactionScope.PushScope() +38
   System.Transactions.TransactionScope..ctor(TransactionScopeOption scopeOption) +355
   Orchard.Data.TransactionManager.Orchard.Data.ITransactionManager.Demand() in C:\Users\CHRIS\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\Data\TransactionManager.cs:26
   Orchard.Data.SessionLocator.For(Type entityType) in C:\Users\CHRIS\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\Data\SessionLocator.cs:33
   Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter..ctor(ShellSettings shellSettings, ISessionLocator sessionLocator, IEnumerable`1 commandInterpreters, ISessionFactoryHolder sessionFactoryHolder, IReportsCoordinator reportsCoordinator)


I'm using the MS SQL Server 2005, but the same happens with SQL CE.
Any thoughts?


Nov 16, 2010 at 12:24 PM
Edited Nov 16, 2010 at 2:23 PM


I found the solution but this leads to another problem. But one thing at a time:

1. The Transaction issue

The problem was, that I had some special purpose Content Pages, that need similar dynamic routing like blogs.
So i implemented an IRouteConstraint to decide whether or not the current URL is s page of my content type.

In the implementation of my IRouteConstraint a accessed a Repository to gather all records i need to make my decision.
In the Orchard.Blogs implementation of the same scenario, I recognized, that there is no direct access of database records within die IBlogSlugConstraint (implements IRouteConstraint). Instead there is class called BlogSlugConstraintUpdator which fills the Slugs of the BlogSlugConstraint (implements IBlogSlugConstraint) initially and every time a blog gets manipulated the BlogSlugConstraint gets manipulated too. This is possible because the IBlogSlugConstraint implements ISingletonDependency so, everyone is working with same instance of IBlogSlugConstraint.

I implemented my solution the same way and everything works just like a charm. 


2. The ReturnURL issue

If you click the edit Button of a Blog displayed on the actual Page, you are routed to a different admin controller which is able to manipulate certain content types. If you manipulate the Slug of this content type, the Slug gets updated and BlogSlugConstraint via the Sweep too.
But the ReturnUrl of the Parameters doesn't get updated. So the User is redirected to an URL which cannot be interpreted anymore because it still has the old Slug.

Any thoughts?


Nov 16, 2010 at 5:37 PM
Edited Nov 16, 2010 at 6:25 PM

The ReturnURL issue
The BlogPartHandler should probably be overriding the blog metadata so the edit link for the blog goes to the right place and the blog’s edit page should respect the returnUrl. That’s something we should take care of. I’ll open a bug for that shortly.


Nov 16, 2010 at 6:23 PM

Here's the work item ->