Copied to clipboard

Flag this post as spam?

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


  • Martin H. Schläger 10 posts 100 karma points
    Oct 31, 2019 @ 09:00
    Martin H. Schläger
    0

    Umbraco 8.2 - Creating a member causes "Database cache is NOT ok (rebuild?)" - How to rebuild database from code

    In earliere versions of umbraco like V7.x I was able to call "umbraco.library.RefreshContent();" but I don't see this option in V8?

    The issue is that everytime I create a member (Code or UI) the database status goes from"Database cache is ok" to "Database cache is NOT ok (rebuild?)" and this will sometimes cause other problems in the system, I can solve this by hitting the [Rebuild] button under "Database Cache" - But I can't keep hitting this everytime a user creates a profile. :-/

    Hope someone can help.

    Thanks

  • Steve Megson 151 posts 1022 karma points MVP c-trib
    Oct 31, 2019 @ 11:42
    Steve Megson
    0

    What other problems are you seeing? I can see why the status check is reporting a problem after a member is created, but as far as I can see it shouldn't actually cause any errors other than making the status check think there's a problem.

  • Martin H. Schläger 10 posts 100 karma points
    Oct 31, 2019 @ 14:43
    Martin H. Schläger
    0

    After a member is created and I create standard content (nodes in the content tree) then sometimes (not always) the system can't retrive content and results in and error and other times if I try to move content around in the content tree it comes with an error like (Cant move node with id -1 etc.) then I can rebuild the database cache and everything is fine again... I'll see if I can force these errors and post them in here. - But do you know how to rebuild the database cache from code?

    Failed to publish content with id 1757

    failed to get last child with id=-1

    Exception Details

    Umbraco.Core.Exceptions.PanicException: failed to get last child with id=-1 Stacktrace

    at Umbraco.Web.PublishedCache.NuCache.ContentStore.GetRequiredLinkedNode(Int32 id, String description, Nullable1 gen) at Umbraco.Web.PublishedCache.NuCache.ContentStore.AddTreeNodeLocked(ContentNode content, LinkedNode1 parentLink) at Umbraco.Web.PublishedCache.NuCache.ContentStore.SetBranch(Int32 rootContentId, IEnumerable1 kits) at Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.NotifyLocked(IEnumerable1 payloads, Boolean& draftChanged, Boolean& publishedChanged) at Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.Notify(JsonPayload[] payloads, Boolean& draftChanged, Boolean& publishedChanged) at Umbraco.Web.Cache.ContentCacheRefresher.Refresh(JsonPayload[] payloads) at Umbraco.Core.Sync.ServerMessengerBase.Deliver[TPayload](ICacheRefresher refresher, TPayload[] payload) at Umbraco.Web.Cache.DistributedCache.RefreshByPayload[TPayload](Guid refresherGuid, IEnumerable1 payloads) at Umbraco.Web.Cache.DistributedCacheExtensions.RefreshContentCache(DistributedCache dc, TreeChange1[] changes) at Umbraco.Core.Events.EventDefinition2.RaiseEvent() at Umbraco.Core.Events.QueuingEventDispatcher.ScopeExitCompleted() at Umbraco.Core.Events.QueuingEventDispatcherBase.ScopeExit(Boolean completed) at Umbraco.Core.Scoping.Scope.<>c__DisplayClass72_0.<RobustExit>b__1() at Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) at Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) at Umbraco.Core.Scoping.Scope.RobustExit(Boolean completed, Boolean onException) at Umbraco.Core.Scoping.Scope.Dispose() at Umbraco.Core.Services.Implement.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId, Boolean raiseEvents) at Umbraco.Web.Editors.ContentController.PostPublishById(Int32 id) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.

  • Steve Megson 151 posts 1022 karma points MVP c-trib
    Oct 31, 2019 @ 15:03
    Steve Megson
    0

    Which version are you on? I wonder if your content errors are actually caused by this issue, rather than creating members? Rebuilding the database cache would fix both problems. That issue is fixed in 8.2.1.

    I don't think there's a public API to rebuild the database cache, since it's not really something you should need to do. As a somewhat hacky workaround, you could probably get an instance of NuCacheStatusController from Current.Factory.GetInstance and call its RebuildDbCachemethod.

  • Martin H. Schläger 10 posts 100 karma points
    Oct 31, 2019 @ 15:11
    Martin H. Schläger
    0

    On my dev setup I'm running 8.2.1 and this one also does the status error on member create, but I'll try an update the other site to 8.2.1 and see if that issue is fixed.

    I don't see an interface for "NuCacheStatusController"?

  • Steve Megson 151 posts 1022 karma points MVP c-trib
    Oct 31, 2019 @ 15:23
    Steve Megson
    100

    I've just seen your edit with the exception details, that does look like the problem that was fixed in 8.2.1. I'll put in a PR to fix the problem with the member cache (it's a simple true that should be false).

    I think that Current.Factory.GetInstance(typeof(Umbraco.Web.Editors.NuCacheStatusController)) should work, though it's pretty horrible.

  • Martin H. Schläger 10 posts 100 karma points
    Oct 31, 2019 @ 15:48
    Martin H. Schläger
    0

    Thanks, I just updated to 8.2.1 and it looks like the -1 error is gone, thats good.

    var nuCache = Current.Factory.GetInstance(typeof(Umbraco.Web.Editors.NuCacheStatusController)); nuCache.RebuildDbCache(); Results in: Compiler Error Message: CS1061: 'object' does not contain a definition for 'RebuildDbCache' and no accessible extension method 'RebuildDbCache' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

    And the same if I try to hit ReloadCache();

  • Martin H. Schläger 10 posts 100 karma points
    Oct 31, 2019 @ 16:00
    Martin H. Schläger
    0

    My bad... I had to cast it first

    var nuCache = (Umbraco.Web.Editors.NuCacheStatusController)Current.Factory.GetInstance(typeof(Umbraco.Web.Editors.NuCacheStatusController));
    nuCache.RebuildDbCache();
    

    That works like a charme, thanks a lot!

    Final code:

    var nuCache = (Umbraco.Web.Editors.NuCacheStatusController)Current.Factory.GetInstance(typeof(Umbraco.Web.Editors.NuCacheStatusController));
    if(nuCache.GetStatus().Contains("NOT ok")){
        nuCache.RebuildDbCache();
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft