Orchard CMS Transaction Errors

99封情书 提交于 2019-12-23 21:20:00

问题


We are consistently, randomly getting the following errors on our Orchard site. It seems most prevalent when quickly navigating between pages. There are no other errors in the logs, so I'm not sure how to track down the root cause. We're not doing anything special with ODBC or anything like that (which is what google brought up when searching for this error with regard to Orchard).

[TransactionException: The operation is not valid for the state of the transaction.]
   System.Transactions.TransactionState.EnlistVolatile(InternalTransaction tx, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) +45
   System.Transactions.Transaction.EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions) +159
   NHibernate.Transaction.AdoNetWithDistributedTransactionFactory.EnlistInDistributedTransactionIfNeeded(ISessionImplementor session) +307
   NHibernate.Impl.AbstractSessionImpl.EnlistInAmbientTransactionIfNeeded() +24
   NHibernate.Impl.AbstractSessionImpl.CheckAndUpdateSessionStatus() +23
   NHibernate.Impl.SessionImpl.CreateCriteria(Type persistentClass) +95
   Orchard.ContentManagement.DefaultContentManager.GetManyImplementation(QueryHints hints, Action`2 predicate) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:302
   Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:140
   Orchard.ContentManagement.ContentGetExtensions.Get(IContentManager manager, Int32 id, VersionOptions options, QueryHints hints) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\ContentExtensions.cs:160
   Orchard.Core.Settings.Services.SiteService.GetSiteSettings() in c:\Users\sebros\My Projects\Orchard\src\Orchard.Web\Core\Settings\Services\SiteService.cs:46
   Orchard.Settings.CurrentSiteWorkContext.Get(String name) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Settings\CurrentSiteWorkContext.cs:13
   Orchard.Environment.<>c__DisplayClass7`1.<FindResolverForState>b__2(IWorkContextStateProvider wcsp) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:32
   System.Linq.WhereSelectArrayIterator`2.MoveNext() +69
   System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +179
   Orchard.Environment.WorkContextImplementation.FindResolverForState(String name) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:32
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +64
   Orchard.Environment.WorkContextImplementation.GetState(String name) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:27
   Orchard.WorkContext.get_CurrentSite() in c:\Users\sebros\My Projects\Orchard\src\Orchard\WorkContext.cs:52
   Orchard.Widgets.Filters.WidgetFilter.OnResultExecuting(ResultExecutingContext filterContext) +1222
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +41
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +22
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +257
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +22
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +257
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +22
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +187
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +346
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +30
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +52
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +28
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +15
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +52
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +28
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +15
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +28
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +52
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +28
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +15
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Mvc\Routes\ShellRoute.cs:162
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +875
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +234

and

[TransactionAbortedException: The transaction has aborted.]
   at System.Transactions.TransactionStateAborted.CreateAbortingClone(InternalTransaction tx)
   at System.Transactions.DependentTransaction..ctor(IsolationLevel isoLevel, InternalTransaction internalTransaction, Boolean blocking)
   at System.Transactions.Transaction.DependentClone(DependentCloneOption cloneOption)
   at System.Transactions.TransactionScope.SetCurrent(Transaction newCurrent)
   at System.Transactions.TransactionScope.PushScope()
   at System.Transactions.TransactionScope..ctor(TransactionScopeOption scopeOption, TransactionOptions transactionOptions)
   at Orchard.Data.TransactionManager.Orchard.Data.ITransactionManager.Demand() in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\TransactionManager.cs:line 37
   at Orchard.Data.SessionLocator.For(Type entityType) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\SessionLocator.cs:line 31
   at Orchard.ContentManagement.DefaultContentManager.GetManyImplementation(QueryHints hints, Action`2 predicate) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 301
   at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 140
   at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 111
   at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 107
   at Orchard.Security.Providers.FormsAuthenticationService.GetAuthenticatedUser() in c:\Users\sebros\My Projects\Orchard\src\Orchard\Security\Providers\FormsAuthenticationService.cs:line 94
   at Orchard.Security.CurrentUserWorkContext.<Get>b__0[T](WorkContext ctx) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Security\CurrentUserWorkContext.cs:line 13
   at Orchard.Environment.WorkContextImplementation.<>c__DisplayClass7`1.<FindResolverForState>b__5() in c:\Users\sebros\My Projects\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:line 37
   at Orchard.Environment.WorkContextImplementation.GetState[T](String name) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:line 28
   at Orchard.WorkContext.get_CurrentUser() in c:\Users\sebros\My Projects\Orchard\src\Orchard\WorkContext.cs:line 60
   at Orchard.Security.Authorizer.Authorize(Permission permission, IContent content, LocalizedString message) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Security\Authorizer.cs:line 72
   at Orchard.Security.Authorizer.Authorize(Permission permission) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Security\Authorizer.cs:line 60
   at Orchard.Security.SecurityFilter.OnAuthorization(AuthorizationContext filterContext) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Security\SecurityFilter.cs:line 24
   at System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.<>c__DisplayClass1d.<BeginExecuteCore>b__19()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at Orchard.Mvc.Routes.ShellRoute.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Mvc\Routes\ShellRoute.cs:line 162
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

EDIT:

I also discovered the following error today in the logs...it sounds like some sort of multi-threading bug in Orchard.

[InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.]
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand\ command)
at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String\ method, SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean\ async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,\ RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1\ completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,\ RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior,\ String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes,\ Boolean callable, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters\ queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor\ session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters\ queryParameters)

[GenericADOException: could not execute query [ select providerco0_.Id as Id45_,\ providerco0_.IsEnabled as IsEnabled45_, providerco0_.DisplayName as DisplayN3_45_,\ providerco0_.ProviderName as Provider4_45_, providerco0_.ProviderIdKey as Provider5_45_,\ providerco0_.ProviderSecret as Provider6_45_, providerco0_.ProviderIdentifier\ as Provider7_45_ from NGM_OpenAuthentication_ProviderConfigurationRecord providerco0_\ where providerco0_.ProviderName=@p0 ] Name:p1 - Value:Google [SQL: select\ providerco0_.Id as Id45_, providerco0_.IsEnabled as IsEnabled45_, providerco0_.DisplayName\ as DisplayN3_45_, providerco0_.ProviderName as Provider4_45_, providerco0_.ProviderIdKey\ as Provider5_45_, providerco0_.ProviderSecret as Provider6_45_, providerco0_.ProviderIdentifier\ as Provider7_45_ from NGM_OpenAuthentication_ProviderConfigurationRecord providerco0_\ where providerco0_.ProviderName=@p0]]
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters\ queryParameters)
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session,\ QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters\ queryParameters, ISet`1 querySpaces, IType[] resultTypes)
at NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session,\ QueryParameters queryParameters)
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session,\ QueryParameters queryParameters)
at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters,\ ISessionImplementor session, IList results)
at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters\ queryParameters, IList results)
at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression queryExpression,\ QueryParameters parameters)
at NHibernate.Impl.ExpressionQueryImpl.List()
at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression,\ IQuery query, NhLinqExpression nhQuery)
at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
at Orchard.Data.Repository`1.Get(Expression`1 predicate) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\Repository.cs:line 91
at Orchard.Data.Repository`1.Orchard.Data.IRepository<T>.Get(Expression`1\ predicate) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\Repository.cs:line\ 60
at NGM.OpenAuthentication.Services.ProviderConfigurationService.Get(String\ providerName)
at NGM.OpenAuthentication.Services.OrchardOpenAuthClientProvider.GetClientData(String\ providerName)
at NGM.OpenAuthentication.Shapes.<Discover>b__3(IExternalAuthenticationClient\ client)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at NGM.OpenAuthentication.Shapes.Discover(ShapeTableBuilder builder)
at Orchard.DisplayManagement.Descriptors.DefaultShapeTableManager.<>c__DisplayClass10.<GetShapeTable>b__4(Meta`1\ bindingStrategy) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Descriptors\DefaultShapeTableManager.cs:line 48
at Orchard.Caching.DefaultParallelCacheContext.<>c__DisplayClass5`2.<>c__DisplayClass7.<RunInParallel>b__1()\ in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\DefaultParallelCacheContext.cs:line\ 24
at Orchard.Caching.DefaultParallelCacheContext.TaskWithAcquireContext`1.Execute()\ in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\DefaultParallelCacheContext.cs:line\ 71
at Orchard.Caching.DefaultParallelCacheContext.<RunInParallel>b__2[T,TResult](ITask`1\ task) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\DefaultParallelCacheContext.cs:line\ 30
at System.Linq.Parallel.SelectQueryOperator`2.SelectQueryOperatorResults.GetElement(Int32\ index)
at System.Linq.Parallel.QueryResults`1.get_Item(Int32 index)
at System.Linq.Parallel.ArrayMergeHelper`1.ToArrayElement(Int32 index)
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput&\ currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Linq.Parallel.QueryTask.<.cctor>b__0(Object o)
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()

[AggregateException: One or more errors occurred.]
at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
at System.Linq.Parallel.SpoolingTask.SpoolForAll[TInputOutput,TIgnoreKey](QueryTaskGroupState\ groupState, PartitionedStream`2 partitions, TaskScheduler taskScheduler)
at System.Linq.Parallel.DefaultMergeHelper`2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute()
at System.Linq.Parallel.MergeExecutor`1.Execute()
at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2\ partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler\ taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2\ partitionedStream)
at System.Linq.Parallel.ForAllOperator`1.WrapPartitionedStream[TKey](PartitionedStream`2\ inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping,\ QuerySettings settings)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2\ inputStream)
at System.Linq.Parallel.ScanQueryOperator`1.ScanEnumerableQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1\ recipient)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1\ recipient)
at System.Linq.Parallel.QueryOperator`1.GetOpenedEnumerator(Nullable`1 mergeOptions,\ Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings)
at System.Linq.Parallel.ForAllOperator`1.RunSynchronously()
at System.Linq.ParallelEnumerable.ForAll[TSource](ParallelQuery`1 source,\ Action`1 action)
at System.Linq.Parallel.ArrayMergeHelper`1.Execute()
at System.Linq.Parallel.QueryOperator`1.ExecuteAndGetResultsAsArray()
at System.Linq.ParallelEnumerable.ToArray[TSource](ParallelQuery`1 source)
at Orchard.Caching.DefaultParallelCacheContext.RunInParallel[T,TResult](IEnumerable`1\ source, Func`2 selector) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\DefaultParallelCacheContext.cs:line 27
at Orchard.DisplayManagement.Descriptors.DefaultShapeTableManager.<>c__DisplayClass10.<GetShapeTable>b__3(AcquireContext`1\ x) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Descriptors\DefaultShapeTableManager.cs:line 42
at Orchard.Caching.Cache`2.CreateEntry(TKey k, Func`2 acquire) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\Cache.cs:line 57
at Orchard.Caching.Cache`2.AddEntry(TKey k, Func`2 acquire) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\Cache.cs:line 27
at Orchard.Caching.Cache`2.<>c__DisplayClass2.<Get>b__0(TKey k) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\Cache.cs:line 19
at System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key,\ Func`2 addValueFactory, Func`3 updateValueFactory)
at Orchard.Caching.Cache`2.Get(TKey key, Func`2 acquire) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\Cache.cs:line 17
at Orchard.Caching.DefaultCacheManager.Get[TKey,TResult](TKey key, Func`2\ acquire) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\DefaultCacheManager.cs:line\ 33
at Orchard.DisplayManagement.Descriptors.DefaultShapeTableManager.GetShapeTable(String\ themeName) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Descriptors\DefaultShapeTableManager.cs:line 39

UPDATE 2: New stack trace:

[TransactionException: The operation is not valid for the state of the transaction.]
   System.Transactions.TransactionState.EnlistVolatile(InternalTransaction tx, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) +53
   System.Transactions.Transaction.EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions) +281
   NHibernate.Transaction.AdoNetWithDistributedTransactionFactory.EnlistInDistributedTransactionIfNeeded(ISessionImplementor session) +469
   NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) +353
   NHibernate.Impl.SessionImpl.Get(String entityName, Object id) +454
   NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id) +372
   NHibernate.Impl.SessionImpl.Get(Object id) +389
   Orchard.Data.Repository`1.Get(Int32 id) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\Repository.cs:87
   Orchard.ContentManagement.Handlers.<>c__DisplayClass1.<Loading>b__0(TRecord prior) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\Handlers\StorageFilter.cs:54
   Orchard.ContentManagement.Utilities.LazyField`1.GetValue() in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\Utilities\LazyField.cs:24
   Orchard.Users.Models.RegistrationSettingsPart.get_UsersCanRegister() +16
   ASP._Page_Modules_Orchard_Users_Views_LogOn_cshtml.Execute() in c:\Users\jeff_000\documents\visual studio 2012\projects\cabwithme.orchard\Modules\Orchard.Users\Views\LogOn.cshtml:4
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +158
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:137
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.<>c__DisplayClass28.<Discover>b__15(DisplayContext displayContext) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:118
   Orchard.DisplayManagement.Descriptors.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:55
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:179
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:88
   Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Users\sebros\My Projects\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:71
   ClaySharp.<>c__DisplayClass16.<InvokeMember>b__13() in C:\Users\sebros\My Projects\Clay\src\ClaySharp\ClayBehaviorCollection.cs:29
   ClaySharp.ClayBehaviorCollection.Execute(Func`1 proceed, Func`3 linker) in C:\Users\sebros\My Projects\Clay\src\ClaySharp\ClayBehaviorCollection.cs:13
   ASP._Page_Core_Shapes_Views_ShapeResult_Display_cshtml.Execute() in c:\Users\jeff_000\documents\visual studio 2012\projects\cabwithme.orchard\Core\Shapes\Views\ShapeResult\Display.cshtml:1
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196
   Orchard.Mvc.ViewEngines.ThemeAwareness.<>c__DisplayClass7.<FindView>b__5(ViewContext viewContext, TextWriter writer, IViewDataContainer viewDataContainer) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:60
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
   System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +33
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +854172

   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

回答1:


So, I had the same sort of issue with an Orchard site hosted on SQL Azure I deployed recently - intermittent transaction errors, not much to go against in the logs, etc.

What finally fixed it for me (and it may or may not work for you, but it's worth a shot) was adding Enlist=false; to the connection string (in settings.txt in App_Data/Sites/Default).

I came across this on a blog post someone made about EntityFramework and SQL Azure and figured it was worth a shot with NHibernate also.




回答2:


Seems like the OpenAuthentication module is performing some database work during a call to NGM.OpenAuthentication.Shapes.Discover(ShapeTableBuilder builder). This method is called by Orchard in parallel when preparing the shape table for caching. So it may or may not be ran on a different thread than the request one. No database operations should ever happen there without suppressing the current TransactionScope first.

Orchard 1.6 (and earlier) uses an ambient transaction (TransactionScope) over the whole request (it starts and ends when request starts and ends). So there may (and will) be situations when the request thread finishes before the spawned thread. It's perfectly normal. But... if there's a database operation being performed on that thread - it will fail because the underlying transaction has already been finished.

It's not an Orchard bug, but a possible bug in the OpenAuthentication module so it would be best to contact its author. But first, try to grab the latest source code from the repository (Gallery module may be way outdated) and try to repro.



来源:https://stackoverflow.com/questions/16268287/orchard-cms-transaction-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!