Orchard CMS 事务错误

3
我们的Orchard网站经常出现以下错误。在快速导航页面时似乎最为常见。日志中没有其他错误,因此我不知道如何找到根本原因。我们没有使用ODBC或类似的东西(这是在搜索与Orchard相关的此错误时Google返回的信息)。
[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

并且

[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)

编辑:

我今天还在日志中发现了以下错误......听起来像是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

更新2: 新的堆栈跟踪:

[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

默认的那些,再加上 CKEditor、NGM.OpenAuthentication 和一个自定义的。如果能帮助我找到问题的原因,我会考虑禁用它们……但是从 Orchard 给出的异常信息中并没有关于潜在问题的任何信息。 - Jeff
1
使用TransactionScope存在很多问题(模糊的异常消息、性能问题、MSDTC等)。自从1.7版本(当前的1.x分支)开始,我们将仅使用显式的NHibernate事务。这将解决大部分问题,并允许异步场景。如果您可以升级,那么应该尽快升级。 - Piotr Szmyd
另外,在我的代码库中,我没有使用事务范围。不确定其他模块情况如何。 - Jeff
如果那确实是问题,您有什么解决建议吗? - Jeff
尝试从存储库下载该OpenAuth的最新源代码。 - Hazza
显示剩余2条评论
2个回答

4
似乎OpenAuthentication模块在调用NGM.OpenAuthentication.Shapes.Discover(ShapeTableBuilder builder)过程中执行了一些数据库操作。在准备缓存的形状表时,Orchard会并行调用此方法。因此,它可能在与请求不同的线程上运行。在没有抑制当前TransactionScope的情况下,不应该在此处执行任何数据库操作。
Orchard 1.6(及更早版本)在整个请求期间都使用环境事务(TransactionScope)(在请求开始和结束时启动和结束)。因此,在派生线程终止之前,请求线程可能(且将)完成。这是完全正常的。但是...如果在该线程上执行数据库操作-它将失败,因为基础事务已经完成。
这不是Orchard的bug,而是OpenAuthentication模块可能存在的bug,因此最好联系其作者。但首先,请尝试从存储库获取最新的源代码(Gallery模块可能已过时),并尝试再现。

1
你说得完全正确。他在最新的源代码中修复了它。我看到他将数据访问代码移动到OnDisplay委托内部。谢谢! - Jeff
实际上,他在我之前的几天版本中修复了它。 - Jeff
好的...所以我正在取得进展。我更新了模块的代码...现在我在LogOn页面上只收到另一个交易错误。我关闭了我的代码,附加到工作进程并观察了根本原因:事务管理器已禁用其对远程/网络事务的支持。(HRESULT异常:0x8004D024)。看起来它正在尝试升级到DTC,因为它正在创建多个SqlConnection或其他东西。我在云托管上,无法使用DTC。如何阻止Orchard创建这个环境事务? - Jeff
我的猜测是,它升级到DTC的唯一原因是Orchard试图在TransactionScope内打开多个并发的SqlConnection。这里只有一个数据库。 - Jeff

2
所以,我最近在部署在SQL Azure上的Orchard网站中遇到了类似的问题 - 间歇性的事务错误,日志中没有太多可用的信息等等。
对我最终起作用的方法(也许对你有用,但也可能不行)是在连接字符串中添加Enlist=false;(在App_Data / Sites / Default的settings.txt中)。
我在关于EntityFramework和SQL Azure的博客文章中发现了这个方法,并想着在NHibernate中也值得一试。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接