3
Vote

Deadlocking on GetMenus

description

Hi,

We have released your module to our server and are constantly getting deadlock situations, also running it with NHProf shows quite a lot of issues, (that may be fixed with 1.4)

The site has the menu set as the Header and the Footer so is on every page.

We think that they are editing the menu whilst the site is being used.

Any help would be appreciated.

file attachments

comments

Sarkie wrote Feb 17, 2012 at 12:44 PM

I had a look at GetMenus and it looks like you removed caching.

public IEnumerable<AdvancedMenuPart> GetMenus()
    {
        //return _cacheManager.Get(CachePrefix,
        //    (ctx) =>
        //    {
        //        MonitorSignal(ctx);
                return _contentManager.Value.Query<AdvancedMenuPart, AdvancedMenuPartRecord>().List();
        //    });
    }
Couldn't you put it back ?

pszmyd wrote Feb 17, 2012 at 6:31 PM

The caching thing that's commented out was not well thought of (content items should not be directly cached, because that usually ends with lots of NHibernate-related issues).
I'm on implementing caching now so it should be there in couple of days.

pszmyd wrote Feb 17, 2012 at 6:43 PM

Btw - thanks for the info about deadlocks. I'll investigate it, but I'm afraid it's not the issue with the module. At least not only. Db operations it does are almost only selects, nothing fancy.

The only thing I'm aware of is huge number of queries being done by the module... It puts a big load on DB server, so if the server itself is not performant enough - it's going to be an issue. In conjunction with database being saturated you may end up with a deadlock at some point.

Caching is only a partial solution to the problem. First of all, I have to work on lightening the load module puts on the db.

Sarkie wrote Feb 20, 2012 at 11:29 AM

Thanks for taking the time to look at this, I'm getting the db profiled too, so hopefully will see what events can cause the deadlocking issue.

Don't even know if nhibernate issues (nolock) I assume so...

I'll keep an eye on it with your updates, will the fixes be for a 1.3 compatible version?

Sarkie wrote Jun 18, 2012 at 12:39 PM

Got another Dead Lock, here's the error log output.


2012-06-18 13:35:30 - ,470 [8] Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCo...
,470 [8] Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator - NullReferenceException thrown from IContentPartDriver by Szmyd.Orchard.Modules.Menu.Drivers.MenuWidgetPartDriver System.NullReferenceException: Object reference not set to an instance of an object. at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in d:\Builds\OrchardFull\src\Orchard\ContentManagement\DefaultContentManager.cs:line 190 at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Orchard.ContentManagement.DefaultContentQuery.ContentQuery1.Orchard.ContentManagement.IContentQuery<T>.List() in d:\Builds\OrchardFull\src\Orchard\ContentManagement\DefaultContentQuery.cs:line 191 at Szmyd.Orchard.Modules.Menu.Services.MenuService.GetMenus() at Szmyd.Orchard.Modules.Menu.Providers.NavigationProviderFactory.<get_Providers>d__2.MoveNext() at Orchard.UI.Navigation.NavigationManager.<GetSources>d__c.MoveNext() in d:\Builds\OrchardFull\src\Orchard\UI\Navigation\NavigationManager.cs:line 90 at System.Linq.Enumerable.<SelectManyIterator>d__142.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Orchard.UI.Navigation.NavigationManager.Merge(IEnumerable1 sources) in d:\Builds\OrchardFull\src\Orchard\UI\Navigation\NavigationManager.cs:line 131 at Orchard.UI.Navigation.NavigationManager.BuildMenu(String menuName) in d:\Builds\OrchardFull\src\Orchard\UI\Navigation\NavigationManager.cs:line 29 at Szmyd.Orchard.Modules.Menu.Drivers.MenuWidgetPartDriver.<>c__DisplayClassd.<Display>b__8() at Orchard.ContentManagement.Drivers.ContentPartDriver1.<>c__DisplayClassd.<ContentShape>b__c(BuildShapeContext ctx) in d:\Builds\OrchardFull\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 108 at Orchard.ContentManagement.Drivers.ContentPartDriver1.<>c__DisplayClass13.<ContentShapeImplementation>b__12(BuildShapeContext ctx) in d:\Builds\OrchardFull\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 116 at Orchard.ContentManagement.Drivers.ContentShapeResult.ApplyImplementation(BuildShapeContext context, String displayType) in d:\Builds\OrchardFull\src\Orchard\ContentManagement\Drivers\ContentShapeResult.cs:line 37 at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable1 events, Action1 dispatch, ILogger logger) in d:\Builds\OrchardFull\src\Orchard\InvokeExtensions.cs:line 19
2012-06-18 13:35:30 - ,017 [8] Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCo...
,017 [8] Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator - ADOException thrown from IContentPartDriver by Szmyd.Orchard.Modules.Menu.Drivers.MenuWidgetPartDriver NHibernate.ADOException: could not execute query [ SELECT this_.Id as Id180_3_, this_.Number as Number180_3_, this_.Published as Published180_3_, this_.Latest as Latest180_3_, this_.Data as Data180_3_, this_.ContentItemRecord_id as ContentI6_180_3_, contentite1_.Id as Id179_0_, contentite1_.Data as Data179_0_, contentite1_.ContentType_id as ContentT3_179_0_, advancedme2_.Id as Id176_1_, advancedme2_.Name as Name176_1_, contenttyp6_.Id as Id181_2_, contenttyp6_.Name as Name181_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id inner join Szmyd_Orchard_Modules_Menu_AdvancedMenuPartRecord advancedme2_ on contentite1_.Id=advancedme2_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp6_ on contentite1_.ContentType_id=contenttyp6_.Id WHERE this_.Published = @p0 ] Positional parameters: #0>True [SQL: SELECT this_.Id as Id180_3_, this_.Number as Number180_3_, this_.Published as Published180_3_, this_.Latest as Latest180_3_, this_.Data as Data180_3_, this_.ContentItemRecord_id as ContentI6_180_3_, contentite1_.Id as Id179_0_, contentite1_.Data as Data179_0_, contentite1_.ContentType_id as ContentT3_179_0_, advancedme2_.Id as Id176_1_, advancedme2_.Name as Name176_1_, contenttyp6_.Id as Id181_2_, contenttyp6_.Name as Name181_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id inner join Szmyd_Orchard_Modules_Menu_AdvancedMenuPartRecord advancedme2_ on contentite1_.Id=advancedme2_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp6_ on contentite1_.ContentType_id=contenttyp6_.Id WHERE this_.Published = @p0] ---> System.Data.SqlClient.SqlException: Transaction (Process ID 130) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.HasMoreRows() at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) at NHibernate.Driver.NHybridDataReader.Read() 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) --- End of inner exception stack trace --- at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) at NHibernate.Impl.CriteriaImpl.List(IList results) at NHibernate.Impl.CriteriaImpl.ListT at Orchard.ContentManagement.DefaultContentQuery.ContentQuery1.Orchard.ContentManagement.IContentQuery<T>.List() in d:\Builds\OrchardFull\src\Orchard\ContentManagement\DefaultContentQuery.cs:line 191 at Szmyd.Orchard.Modules.Menu.Services.MenuService.GetMenus() at Szmyd.Orchard.Modules.Menu.Providers.NavigationProviderFactory.<get_Providers>d__2.MoveNext() at Orchard.UI.Navigation.NavigationManager.<GetSources>d__c.MoveNext() in d:\Builds\OrchardFull\src\Orchard\UI\Navigation\NavigationManager.cs:line 90 at System.Linq.Enumerable.<SelectManyIterator>d__142.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Orchard.UI.Navigation.NavigationManager.Merge(IEnumerable1 sources) in d:\Builds\OrchardFull\src\Orchard\UI\Navigation\NavigationManager.cs:line 131 at Orchard.UI.Navigation.NavigationManager.BuildMenu(String menuName) in d:\Builds\OrchardFull\src\Orchard\UI\Navigation\NavigationManager.cs:line 29 at Szmyd.Orchard.Modules.Menu.Drivers.MenuWidgetPartDriver.<>c__DisplayClassd.<Display>b__8() at Orchard.ContentManagement.Drivers.ContentPartDriver1.<>c__DisplayClassd.<ContentShape>b__c(BuildShapeContext ctx) in d:\Builds\OrchardFull\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 108 at Orchard.ContentManagement.Drivers.ContentPartDriver1.<>c__DisplayClass13.<ContentShapeImplementation>b__12(BuildShapeContext ctx) in d:\Builds\OrchardFull\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 116 at Orchard.ContentManagement.Drivers.ContentShapeResult.ApplyImplementation(BuildShapeContext context, String displayType) in d:\Builds\OrchardFull\src\Orchard\ContentManagement\Drivers\ContentShapeResult.cs:line 37 at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable1 events, Action1 dispatch, ILogger logger) in d:\Builds\OrchardFull\src\Orchard\InvokeExtensions.cs:line 19
2012-06-18 13:35:30 - ,001 [8] NHibernate.Util.ADOExceptionReporter - Transaction (Process ID 130...
,001 [8] NHibernate.Util.ADOExceptionReporter - Transaction (Process ID 130) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.