Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John Murphy 5 posts 35 karma points
    Jan 08, 2015 @ 17:36
    John Murphy
    0

    Intermittent high CPU when calling ContentService.GetByID

    Hello all. I have a site running Umbraco version 7.1.8 assembly: 1.0.5394.16131 on IIS 7.5. It is experiencing an intermittent high CPU condition, which I think I have tracked down to a call to ContentService.GetByID. I cannot force the conditon to happen, but I have a process dump taken during the condition. In that dump, I have three requests from the same client, with the same session id, for the same page. I assume the user requested the page, it hung, and he tried two more times.

    The page the user was requesting is a uBlogsy post. In uBlogsyPost.cshtml I am doing the following, in order to only render content on pages which have been published.

    var content = ApplicationContext.Current.Services.ContentService.GetById(Model.Content.Id);
    bool isPublished = content.Published;
    

    The thread with 00:17:50.730 CPU time had the following (truncated) call stack:

    0:037> !clrstack
    OS Thread Id: 0x24c4 (37)
    Child SP       IP Call Site
    37c7e1bc 732366a4 System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.Boolean, mscorlib]].Insert(System.__Canon, Boolean, Boolean)
    37c7e1f0 7319b5bd System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.Boolean, mscorlib]].set_Item(System.__Canon, Boolean)
    37c7e1f8 22a1ccc4 Umbraco.Core.Models.EntityBase.TracksChangesEntityBase.OnPropertyChanged(System.Reflection.PropertyInfo)
    37c7e210 22a1e378 Umbraco.Core.Models.EntityBase.TracksChangesEntityBase.SetPropertyValueAndDetectChanges[[System.__Canon, mscorlib]](System.Func`2<System.__Canon,System.__Canon>, System.__Canon, System.Reflection.PropertyInfo)
    37c7e22c 22f0e664 Umbraco.Core.Models.ContentType.set_AllowedTemplates(System.Collections.Generic.IEnumerable`1<Umbraco.Core.Models.ITemplate>)
    37c7e558 74413de2 [DebuggerU2MCatchHandlerFrame: 37c7e558] 
    37c7e320 74413de2 [HelperMethodFrame_PROTECTOBJ: 37c7e320] System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
    37c7e5f4 73189b5d System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
    37c7e618 7322e52d System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
    37c7e64c 73236132 System.Reflection.RuntimePropertyInfo.SetValue(System.Object, System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
    37c7e678 732360b6 System.Reflection.RuntimePropertyInfo.SetValue(System.Object, System.Object, System.Object[])
    37c7e688 22f0b8c7 Umbraco.Core.Models.DeepCloneHelper.DeepCloneRefProperties(Umbraco.Core.Models.IDeepCloneable, Umbraco.Core.Models.IDeepCloneable)
    37c7e6d0 22f0b3dc Umbraco.Core.Models.EntityBase.Entity.DeepClone()
    37c7e6e0 22f0b31f Umbraco.Core.Models.ContentTypeBase.DeepClone()
    37c7e6f0 22f0b229 Umbraco.Core.Models.ContentTypeCompositionBase.DeepClone()
    37c7e708 239f2ebe Umbraco.Core.Models.Content.DeepClone()
    37c7e718 22a12f36 Umbraco.Core.Persistence.Caching.RuntimeCacheProvider.GetById(System.Type, System.Guid)
    37c7e738 22a12ce7 Umbraco.Core.Persistence.Repositories.RepositoryBase`2[[System.Int32, mscorlib],[System.__Canon, mscorlib]].TryGetFromCache(Int32)
    37c7e774 22a12b7c Umbraco.Core.Persistence.Repositories.RepositoryBase`2[[System.Int32, mscorlib],[System.__Canon, mscorlib]].Get(Int32)
    37c7e794 2316ec48 Umbraco.Core.Services.ContentService.GetById(Int32)
    37c7e7c0 2316e640 ASP._Page_Views_uBlogsyPost_cshtml.Execute()
    ...
    

    So, I have a couple of questions. 1) Is it unsafe to call ContentService.GetByID for the current Model.Content in a view? Is there some other way to figure out if the current node is published? 2) Is this a known bug in ContentService.GetByID? I haven't reviewed the source yet, but I was surprised to see this call making any kind of changes to a dictionary. The page that was being requested was last saved and published December 1, so I would have expected this call to just fetch from the existing disk cache, without changing anything.

    Thanks for any help anyone can offer. I've been puzzling over this for a while.

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Jan 09, 2015 @ 19:33
    Sebastiaan Janssen
    0

    The ContentService goes straight to the database so yeas, it is unsafe to call if you are expecting to read from cached content.. :-)

    When querying for content always use the Model.Content calls or dynamic versions of that. Here's some cheat sheets (they say Umbraco 6 but are also valid for v7): http://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets

  • John Murphy 5 posts 35 karma points
    Jan 09, 2015 @ 20:22
    John Murphy
    0

    Thanks Sebastiaan, that's good to know. I don't want to do that even if I weren't having issues. Is there a good way to know if the current page has been published? I can check if the page has a preview url, which is probably good enough for my purposes, but I can't see anything equivalent to Content.Published.

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Jan 09, 2015 @ 20:41
    Sebastiaan Janssen
    100

    You can only get a page from the cache if it is published, so if Model.Content.TypedContent(yourId) doesn't return a page, it's not in the cache.

    And the "current" page cannot be shown on the frontend if it isn't published, so checking if the "current" page is publish would be superfluous.. you either get a 404 (not published) or a page.

  • John Murphy 5 posts 35 karma points
    Jan 09, 2015 @ 20:42
    John Murphy
    0

    Perfect, thanks, but the current page can be unpublished if you're in preview mode.

  • Bilal khan 35 posts 58 karma points
    Sep 29, 2015 @ 08:47
    Bilal khan
    0

    Hi Guys,

    Sorry for adding my problem to this post but really need help to make sense out of everything. I was having similar sort of issues where CPU would jump upto 100% I didnt use GetByID anywhere however I did use CurrentPage.HasValue and Umbraco.Field to read data directly in the template.

    I deleted two newly created pages did a publish of the whole site and removed everything under recycle node and after that haven't experienced the high CPU issue.

    I am still trying to make sense as to why I was getting the issue in the first place and why deleting and republishing the site could potentially be the solution.

    When the CPU was quite high I created a dump file of w3wp and found the following when debugging through windb

    Using windebug found at least 4-5 threads that were taking up to 10 min each all these threads were similar and looking at the stack trace I got the following. Any help or explanation is much appreciated

    OS Thread Id: 0x1008 (38) Child SP IP Call Site 000000db9a9dcac0 00007ffb14611fbc System.Collections.Generic.Dictionary2[[System.__Canon, mscorlib],[System.Boolean, mscorlib]].Insert(System.__Canon, Boolean, Boolean) 000000db9a9dcb50 00007ffab7d1d45e Umbraco.Core.Models.EntityBase.TracksChangesEntityBase.OnPropertyChanged(System.Reflection.PropertyInfo) 000000db9a9dcba0 00007ffab7d16f2c Umbraco.Core.Models.EntityBase.TracksChangesEntityBase.SetPropertyValueAndDetectChanges[[System.__Canon, mscorlib]](System.Func2, System.Canon, System.Reflection.PropertyInfo) 000000db9a9dcc38 00007ffb15a1f0b7 [StubHelperFrame: 000000db9a9dcc38] 000000db9a9dcee0 00007ffb15a1f0b7 [DebuggerU2MCatchHandlerFrame: 000000db9a9dcee0] 000000db9a9dd1f8 00007ffb15a1f0b7 [HelperMethodFramePROTECTOBJ: 000000db9a9dd1f8] System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean) 000000db9a9dd370 00007ffb14553b4c System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[]) 000000db9a9dd3e0 00007ffb14551273 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) 000000db9a9dd460 00007ffb146182cc System.Reflection.RuntimePropertyInfo.SetValue(System.Object, System.Object, System.Object[]) 000000db9a9dd4b0 00007ffab7d2f3bd Umbraco.Core.Models.DeepCloneHelper.DeepCloneRefProperties(Umbraco.Core.Models.IDeepCloneable, Umbraco.Core.Models.IDeepCloneable) 000000db9a9dd560 00007ffab7d4281d Umbraco.Core.Models.ContentTypeCompositionBase.DeepClone() 000000db9a9dd5b0 00007ffab7ba62ad Umbraco.Core.Persistence.Caching.RuntimeCacheProvider.GetByIds(System.Type, System.Collections.Generic.List1<System.Guid>) 000000db9a9dd6a0 00007ffab7ba4895 Umbraco.Core.Persistence.Repositories.RepositoryBase2[[System.Int32, mscorlib],[System.Canon, mscorlib]].GetAll(Int32[]) 000000db9a9dd710 00007ffab7d37950 Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository1+ContentTypeQueryMapper[[System.__Canon, mscorlib]].MapContentTypeChildren[[System.__Canon, mscorlib]](Umbraco.Core.Models.IContentTypeComposition[], Umbraco.Core.Persistence.Database, System.__Canon, System.Collections.Generic.IDictionary2<>1<Int32>>) 000000db9a9dd7d0 00007ffab7d20d3c Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository1+ContentTypeQueryMapper[[System.Canon, mscorlib]].GetContentTypes[[System.Canon, mscorlib]](Int32[], Umbraco.Core.Persistence.Database, System.Canon, Umbraco.Core.Persistence.Repositories.ITemplateRepository) 000000db9a9dd830 00007ffab7d208e8 Umbraco.Core.Persistence.Repositories.ContentTypeRepository.PerformGetAll(Int32[]) 000000db9a9dd8a0 00007ffab7ba4e52 Umbraco.Core.Persistence.Repositories.RepositoryBase2[[System.Int32, mscorlib],[System.__Canon, mscorlib]].GetAll(Int32[]) 000000db9a9dd910 00007ffab7d1f4af Umbraco.Core.Persistence.Repositories.ContentTypeRepository.PerformGetByQuery(Umbraco.Core.Persistence.Querying.IQuery1) 000000db9a9dd970 00007ffab7d1f1cc Umbraco.Core.Persistence.Repositories.RepositoryBase2[[System.Int32, mscorlib],[System.__Canon, mscorlib]].GetByQuery(Umbraco.Core.Persistence.Querying.IQuery1) 000000db9a9dd9c0 00007ffab7b8d484 Umbraco.Core.Services.ContentTypeService.GetContentType(System.String) 000000db9a9dda50 00007ffab7b8c7a7 Umbraco.Core.Models.PublishedContent.PublishedContentType.CreatePublishedContentType(Umbraco.Core.Models.PublishedItemType, System.String) 000000db9a9ddab0 00007ffab7b8c6af Umbraco.Core.Cache.CacheProviderExtensions+<>cDisplayClass91[[System.__Canon, mscorlib]].<GetCacheItem>b__8() 000000db9a9ddae0 00007ffab7b8c67f Umbraco.Core.Cache.StaticCacheProvider+<>c__DisplayClass1a.<GetCacheItem>b__19(System.String) 000000db9a9ddb10 00007ffb14e7aae3 System.Collections.Concurrent.ConcurrentDictionary2[[System.Canon, mscorlib],[System.Canon, mscorlib]].GetOrAdd(System.Canon, System.Func2<System.__Canon,System.__Canon>) 000000db9a9ddb70 00007ffab7b8c642 Umbraco.Core.Cache.StaticCacheProvider.GetCacheItem(System.String, System.Func1) 000000db9a9ddbc0 00007ffab7b8bda4 Umbraco.Core.Cache.CacheProviderExtensions.GetCacheItem[[System.Canon, mscorlib]](Umbraco.Core.Cache.ICacheProvider, System.String, System.Func1<System.__Canon>) 000000db9a9ddc40 00007ffab7b8bcbc Umbraco.Core.Models.PublishedContent.PublishedContentType.Get(Umbraco.Core.Models.PublishedItemType, System.String) 000000db9a9ddca0 00007ffab7b8b4f6 Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Initialize() 000000db9a9ddd30 00007ffab7d2fd5b Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.get_DocumentTypeAlias() 000000db9a9ddd60 00007ffab7d2fcb4 Umbraco.Core.Models.PublishedContent.PublishedContentModelFactory.CreateModel(Umbraco.Core.Models.IPublishedContent) 000000db9a9dddb0 00007ffab7d2fbbd Umbraco.Core.Models.PublishedContent.PublishedContentExtensionsForModels.CreateModel(Umbraco.Core.Models.IPublishedContent) 000000db9a9dddf0 00007ffab7d48907 Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.InitializeChildren() 000000db9a9dde60 00007ffab7b898aa Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.ConvertToDocument(System.Xml.XmlNode, Boolean) 000000db9a9ddeb0 00007ffab7b890a0 Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.DetermineIdByRoute(Umbraco.Web.UmbracoContext, Boolean, System.String, Boolean) 000000db9a9ddf40 00007ffab7b88cf4 Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetByRoute(Umbraco.Web.UmbracoContext, Boolean, System.String, System.Nullable1) 000000db9a9ddfc0 00007ffab7b88b17 Umbraco.Web.Routing.ContentFinderByNiceUrl.FindContent(Umbraco.Web.Routing.PublishedContentRequest, System.String) 000000db9a9de050 00007ffab7b889e4 Umbraco.Web.Routing.ContentFinderByNiceUrl.TryFindContent(Umbraco.Web.Routing.PublishedContentRequest) 000000db9a9de0c0 00007ffb113a1095 System.Linq.Enumerable.Any[[System.Canon, mscorlib]](System.Collections.Generic.IEnumerable1<System.__Canon>, System.Func2) 000000db9a9de110 00007ffab7b87e06 Umbraco.Web.Routing.PublishedContentRequestEngine.FindPublishedContent() 000000db9a9de170 00007ffab7b87c42 Umbraco.Web.Routing.PublishedContentRequestEngine.FindPublishedContentAndTemplate() 000000db9a9de1c0 00007ffab7b835d7 Umbraco.Web.Routing.PublishedContentRequestEngine.PrepareRequest() 000000db9a9de200 00007ffab7b7eabd Umbraco.Web.UmbracoModule.ProcessRequest(System.Web.HttpContextBase) 000000db9a9de280 00007ffb0e02cccc System.Web.HttpApplication+SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 000000db9a9de2e0 00007ffb0e00d495 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 000000db9a9de380 00007ffb0e02ab8a System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception) 000000db9a9de4d0 00007ffb0e00d6a3 System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback) 000000db9a9de520 00007ffb0e0075de System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext) 000000db9a9de5c0 00007ffb0e010561 System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32) 000000db9a9de7d0 00007ffb0e00ff92 System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32) 000000db9a9de820 00007ffb0e765a81 DomainNeutralILStubClass.ILSTUBReversePInvoke(Int64, Int64, Int64, Int32) 000000db9a9df038 00007ffb1597b42e [InlinedCallFrame: 000000db9a9df038] System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus ByRef) 000000db9a9df038 00007ffb0e0b959b [InlinedCallFrame: 000000db9a9df038] System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus ByRef) 000000db9a9df010 00007ffb0e0b959b DomainNeutralILStubClass.ILSTUBPInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef) 000000db9a9df0e0 00007ffb0e01074f System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32) 000000db9a9df2f0 00007ffb0e00ff92 System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32) 000000db9a9df340 00007ffb0e765a81 DomainNeutralILStubClass.ILSTUB_ReversePInvoke(Int64, Int64, Int64, Int32) 000000db9a9df538 00007ffb1597b683 [ContextTransitionFrame: 000000db9a9df538]..

    Many thanks A

  • Sam Bancroft 2 posts 72 karma points
    Nov 02, 2015 @ 15:27
    Sam Bancroft
    0

    Hi Bilal,

    I've been experiencing an issue very similar to yours, I get very high CPU usage when calling the content service. There are threads hanging when calling content service GetContentType. When I've analysed a memory dump, I've found a stack trace like the one you've posted here.

    Did you ever find a resolution to the issue?

    Many thanks, Sam

  • Bilal khan 35 posts 58 karma points
    Nov 02, 2015 @ 17:37
    Bilal khan
    1

    Hi Sam,

    What version of Umbraco you are using? My issue was related to a bug in 7.2.2 where the thread was hanging and I was getting High CPU.

    After upgrading to 7.2.8 I haven't seen the High CPU issue!

    Thanks A

  • Sam Bancroft 2 posts 72 karma points
    Nov 09, 2015 @ 10:00
    Sam Bancroft
    0

    Hi

    I'm running 7.2.1, I'm going to try an upgrade and see if it helps,

    Thanks for your advice, Sam

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Feb 28, 2016 @ 22:13
Please Sign in or register to post replies

Write your reply to:

Draft