That is actually not a bad idea. I will file a bug to see how my colleagues think about it
This issue is fixed in EpiServer Commerce version 12.5.1 and the packages may be available on next week.
Commerce also uses the "Trim Content Versions" job to trim Commerce content for cleaning up old previous versions of catalog entries base on the uiMaxVersions setting.
Hi @Giang,
I get the following error from "EPiServer.Util.Internal.TrimContentVersionsJob". Seems that the id of the content version is missing in the error message.
Error when trying to delete version with id 'EPiServer.DataAbstraction.ContentVersion'
System.NullReferenceException: Object reference not set to an instance of an object.
at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadContentPropertiesVersion(DataRow[] rowsCollection, CatalogContentBase content)
at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentBuilder.ReadProperties(DataTable table, Dictionary`2 contentMap)
at EPiServer.Commerce.Catalog.Provider.Construction.NodeBuilder.CreateVersions(IList`1 contentLinks)
at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentVersions(IList`1 contentVersions)
at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
at EPiServer.Core.ContentProvider.<>c__DisplayClass121_0.<LoadContentFromCacheOrRepository>b__0()
at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy)
at EPiServer.Core.Internal.ContentInstanceCache.ReadThrough(ContentReference contentLink, String selectedLanguage, Func`1 readValue)
at EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector)
at EPiServer.Core.Internal.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions)
at EPiServer.Core.Internal.DefaultContentLoader.TryGet[T](ContentReference contentLink, LoaderOptions loaderOptions, T& content)
at EPiServer.Marketing.Testing.Web.TestHandler.ContentEventsOnDeletingContentVersion(Object sender, ContentEventArgs contentEventArgs)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at EPiServer.Core.Internal.DefaultContentEvents.RaiseCancellableContentEvent(String key, String defaultReason, ContentEventArgs eventArgs)
at EPiServer.Core.Internal.ProviderAwareContentVersionRepository.Delete(ContentReference contentLink, AccessLevel access)
at EPiServer.Util.Internal.TrimContentVersionsJob.<>c__DisplayClass15_3.<Execute>b__4()
at EPiServer.Util.Internal.TrimContentVersionsJob.ExecuteInTryCatch(Func`1 failureAction, Action action)
@Kristian: can you put this file in bin and try again please https://www.dropbox.com/s/nbwhdzd842wx9vw/EPiServer.Business.Commerce.pdb?dl=0
I would like to have a more detailed stacktrace
Tried but doesnt give me more info in the log.
The thing in the error message is that it says "Error when trying to delete version with id 'EPiServer.DataAbstraction.ContentVersion'".
Should be the content version id instead of 'EPiServer.DataAbstraction.ContentVersion'?
Another thing is when running the job multiple times after each other it just returns the same message.
https://imgur.com/a/cZn8Yda
It should give you the number of offending line, that is what I'm interested in :)
When getting above error I also get this which contain the content version id:
Failed to Read cacheKey = 'EPContentVersion:1073741851_4590_CatalogContent' System.NullReferenceException: Object reference not set to an instance of an object. at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadContentPropertiesVersion(DataRow[] rowsCollection, CatalogContentBase content) at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentBuilder.ReadProperties(DataTable table, Dictionary`2 contentMap) at EPiServer.Commerce.Catalog.Provider.Construction.NodeBuilder.CreateVersions(IList`1 contentLinks) at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc) at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentVersions(IList`1 contentVersions) at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader) at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector) at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector) at EPiServer.Core.ContentProvider.<>c__DisplayClass121_0.<LoadContentFromCacheOrRepository>b__0() at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy)
I get the same two errors and no previous versions is shown in Commerce UI when I navigate to the node content in Commerce catalog UI in the production environment where we currently is in Episerver.Commerce 12.14.0 so this issue is properly not related to Episerver.Commerce 12.15.1 and the support of Commerce content in "Trim Content Versions" but some data that is messed up.
I will try to investigate and see if I can get an more detailed stacktrace.
Hi again,
@Quan I have tried adding the pdb file to the bin folder in local dev where I can reproduce the error. I run as <compilation debug=true ..> in web.config but I do not get a more detailed stackstrace where code line numbers is shown :/
at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadContentPropertiesVersion(DataRow[] rowsCollection, CatalogContentBase content)
at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentBuilder.ReadProperties(DataTable table, Dictionary`2 contentMap)
at EPiServer.Commerce.Catalog.Provider.Construction.NodeBuilder.CreateVersions(IList`1 contentLinks)
at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentVersions(IList`1 contentVersions)
at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
at EPiServer.Core.ContentProvider.<>c__DisplayClass121_0.<LoadContentFromCacheOrRepository>b__0()
at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy)
at EPiServer.Core.Internal.ContentInstanceCache.ReadThrough(ContentReference contentLink, String selectedLanguage, Func`1 readValue)
at EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector)
at EPiServer.Core.Internal.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions)
at EPiServer.Core.Internal.DefaultContentLoader.TryGet[T](ContentReference contentLink, LoaderOptions loaderOptions, T& content)
at EPiServer.Marketing.Testing.Web.TestHandler.ContentEventsOnDeletingContentVersion(Object sender, ContentEventArgs contentEventArgs)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at EPiServer.Core.Internal.DefaultContentEvents.RaiseCancellableContentEvent(String key, String defaultReason, ContentEventArgs eventArgs)
at EPiServer.Core.Internal.ProviderAwareContentVersionRepository.Delete(ContentReference contentLink, AccessLevel access)
at *.*.*.Maintenance.TestTestJob.ExecuteInternal() in C:\**\Maintenance\TestTestJob.cs:line 85
As mentioned is the error that occurs when running the "Trim Content Versions" not related to this job.
I get the same error if I from code tries to load the previous version or try deleting it using IContentVersionRepository. Seems data is corrupted somehow and I get the error:
I have narrowed it down to that I only have this problem with NodeContent. Not ProductContent or VariationContent.
It is not a general issue for all NodeContent i Catalog. Only a few have this issue and it is only with one previous version for each NodeContent that has the problem.
I have tried taking a look in the database in the table ecfVersionProperty and comparing rows between the version that gets the error and other versions and I can see that the different versions doesnt have the exact same rows ([MetaFieldId], [MetaFieldName]) but would guess that the EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadContentPropertiesVersion(DataRow[] rowsCollection, CatalogContentBase content) method should be able to handle that.
That's very strange. As you said it's only with some NodeContent, it might be your database has some problems. Please contact our developer support service for further assistance.
@Quan the EPiServer.Business.Commerce.pdf file in https://www.dropbox.com/s/nbwhdzd842wx9vw/EPiServer.Business.Commerce.pdb?dl=0 is for EPiServer.Business.Commerce.dll version 12.15.1.3487?
In CMS 11 we got the "Trim Content Versions" job for CMS content which uses the uiMaxVersions setting.
Would be nice with a similar built-in job for Commerce content for cleaning up old previous versions of catalog entries.