Glass.Mapper icon indicating copy to clipboard operation
Glass.Mapper copied to clipboard

Item with ID cannot be deleted because it is not found in Sitecore 9.2+

Open markgibbons25 opened this issue 5 years ago • 8 comments
trafficstars

We are getting our logs spammed with messages like

WARN Item with ID={C100A1CF-6205-4F05-A636-0831DBADE1D0} cannot be deleted because it is not found

I traced it back to here https://github.com/mikeedwards83/Glass.Mapper/blob/2bc3e9418bb9d3dd4fedd854e2e0e688dc5a86d1/Source/Glass.Mapper.Sc/RenderingParametersModelFactory.cs#L50

I added a log statement

Sitecore.Diagnostics.Log.Info("GLASS DELETE?", this); item.Delete(); //added for clean up

And confirmed logs:

17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={C100A1CF-6205-4F05-A636-0831DBADE1D0} cannot be deleted because it is not found 17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={88CC0F4C-EB54-4013-8228-83E558CF35AC} cannot be deleted because it is not found 17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={B82C7AC0-46BD-4CD5-9D58-E4D9627646E6} cannot be deleted because it is not found 17368 12:51:07 INFO GLASS DELETE?

It looks like Sitecore in 9.2+ has changed that Delete() to log if the item is not found. Looks like in this case it is an in memory item only. Is it safe to just remove that item.Delete() line and let the GC do its thing? Happy to open a PR if so.

markgibbons25 avatar Feb 20 '20 02:02 markgibbons25

@mikeedwards83 any thoughts on @markgibbons25 suggestion? We are facing the same problem and this is filling up our prod trace logs massively. Thanks for your help!

swissworx avatar May 05 '20 05:05 swissworx

@swissworx Sorry for not responding quicker.

This is indeed annoying, my only worry is that the item just hangs around in memory and cause a memory leak if delete isn't called. Is there a way to tell if the item is removed from memory without the delete?

mikeedwards83 avatar May 05 '20 07:05 mikeedwards83

It looks to me like it is going to get cleaned up by the GC just fine. Which leads me to think that we could maybe improve performance here by pooling and reusing these fake items to save the GC some work. I'll do some benchmarking...

markgibbons25 avatar May 05 '20 12:05 markgibbons25

Hi @markgibbons25

We've seen the same behaviour in one of our projects. When could we expect this update to be published on NuGet?

Thanks!

simonethreechillies avatar May 07 '20 13:05 simonethreechillies

Hi @markgibbons25

We've seen the same behaviour in one of our projects. When could we expect this update to be published on NuGet?

Thanks!

I would love to but it's up to @mikeedwards83

markgibbons25 avatar May 08 '20 22:05 markgibbons25

@mikeedwards83 it looks fine to me, I quickly cracked the Sitecore dll open and I couldn't find anything being allocated that is not cleaned up by the GC.

swissworx avatar May 12 '20 01:05 swissworx

Thanks, I will make the change later today and push a beta nuget out.

Glass-Build-Github avatar May 12 '20 08:05 Glass-Build-Github

I have pushed a beta release with this fix, it also contains a flag in the config for backward compatibility. By default it will no longer delete the item, but setting the flag will restore the original logic.

https://github.com/mikeedwards83/Glass.Mapper/commit/74ff5e89e98724e5e258d2201bd9c033c842617d#diff-112f7122b703ee4f85649982cc0c249eR74

mikeedwards83 avatar May 13 '20 07:05 mikeedwards83