question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Umbraco 8 refresh nucache broken after using media service

See original GitHub issue

Umbraco v8.5.3

I have a site where i had to manually import products from csv using content service. After that i had to import media from a pictures folder using media service. There is something wrong because i cant get some pictures using umbraco helper and querying by id (ie. Umbraco.Media(1310)), it gets null. But i can using the content service and then if i save it i can see the picture. Or editing the item using backoffice.

I have tried to rebuild the memory cache (from published status in settings section) but i get this error: System.NullReferenceException: Object reference not set to an instance of an object. First lines of stack trace:

at Umbraco.Web.PublishedCache.NuCache.ContentStore.AddTreeNodeLocked(ContentNode content, LinkedNode`1 parentLink)
   at Umbraco.Web.PublishedCache.NuCache.ContentStore.SetAll(IEnumerable`1 kits)
   at Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.LoadMediaFromDatabaseLocked(IScope scope, Boolean onStartup)
   at Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.NotifyLocked(IEnumerable`1 payloads, Boolean& anythingChanged)
   at Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.Notify(JsonPayload[] payloads, Boolean& anythingChanged)
   at Umbraco.Web.Cache.MediaCacheRefresher.Refresh(JsonPayload[] payloads)
   at Umbraco.Core.Sync.ServerMessengerBase.DeliverLocal[TPayload](ICacheRefresher refresher, TPayload[] payload)
   at Umbraco.Core.Sync.ServerMessengerBase.Deliver[TPayload](ICacheRefresher refresher, TPayload[] payload)
   at Umbraco.Core.Sync.ServerMessengerBase.PerformRefresh[TPayload](ICacheRefresher refresher, TPayload[] payload)
   at Umbraco.Web.Cache.DistributedCache.RefreshByPayload[TPayload](Guid refresherGuid, TPayload[] payload)
   at Umbraco.Web.Cache.DistributedCacheExtensions.RefreshAllMediaCache(DistributedCache dc)
   at Umbraco.Web.Cache.DistributedCacheExtensions.RefreshAllPublishedSnapshot(DistributedCache dc)
   at lambda_method(Closure , Object , Object[] )
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.<GetExecutor>b__0(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

I have tried to rebuild the database cache, it gets no error but the problem persists and after that if i try to rebuild the memory cache i get same error.

Also, i have tried to query all media items in db and use the media service to save again using this code:

var ms = Current.Services.MediaService;

List<int> mediaItems;

        using (var scope = Current.ScopeProvider.CreateScope())
        {

            mediaItems = scope.Database.Query<int>("SELECT id FROM umbracoNode where nodeObjectType='B796F64C-1F99-4FFB-B886-4BF4BC011A9C'").ToList();

        }
var mediaProblems= mediaItems.Where(it => Umbraco.Media(it) == null).ToList();

foreach (var itemId in mediaProblems)
           {

                var obj = ms.GetById(itemId);

                ms.Save(obj);

            }

After that i clean temp files from app_data and restart the app and all the pictures go back. Then if i try to reload cache problem goes back again.

I guess at some point there was an error in the database, but how could i fix this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
nul800sebastiaancommented, Mar 31, 2020

@andersbrohall 9 minutes after you asked… because you asked, of course! 😂 https://twitter.com/umbraco/status/1244921666679046144

Some world pandemic got in the way of our plans, sorry about the delay. 😉

1reaction
teetocommented, Apr 1, 2020

@andersbrohall if you have the same problem it is not solved on 8.6 You better follow the issue here: https://github.com/umbraco/Umbraco-CMS/issues/7868

Read more comments on GitHub >

github_iconTop Results From Across the Web

umbraco 8 refresh nucache broken after using media service
I have a site (Umbraco v8.5.3) where i had to manually import products from csv using content service. After that i had to...
Read more >
Ultimate Umbraco 10 Performance And Caching Guide
NET Core a view can be broken into smaller chunks using something called a view component. One reason why view components improve page...
Read more >
Umbraco: Saving media, not added to cache?
I have a script that imports some legacy media into Umbraco media library. File gets saved, and is vissible in the backend, and...
Read more >
Archive
Read any of these promo marketing magazines for news and information on promotional clothing and the promotional products industry.
Read more >
NuCache fails to rebuild (Umbraco 8) - ActiveTopics
Hi, some media items randomly started to disappear from website, they are returned as null when they are requested from a view. When...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found