November Happy Hour will be moved to Thursday December 5th.

Trim Content Versions job for Commerce catalog content

Vote:
 

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. 

#199892
Edited, Dec 17, 2018 16:24
Vote:
 

That is actually not a bad idea. I will file a bug to see how my colleagues think about it 

#199910
Dec 17, 2018 19:31
Vote:
 

Great thanks :)

#199999
Dec 20, 2018 8:29
Vote:
 

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.

#200128
Jan 03, 2019 3:47
Vote:
 

Very nice. Thanks.

#200132
Jan 03, 2019 8:22
Vote:
 

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)

#200330
Jan 09, 2019 8:59
Vote:
 

Hi Kristian,

I'll take a look.

#200331
Edited, Jan 09, 2019 9:15
Vote:
 

@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 

#200341
Jan 09, 2019 11:36
Vote:
 

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

#200344
Jan 09, 2019 12:18
Vote:
 

It should give you the number of offending line, that is what I'm interested in :) 

#200345
Jan 09, 2019 12:21
Vote:
 

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)

#200347
Jan 09, 2019 12:28
Vote:
 

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.

#200348
Jan 09, 2019 12:41
Vote:
 

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.

#200422
Edited, Jan 11, 2019 13:06
Vote:
 

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. 

#200423
Jan 11, 2019 13:10
Vote:
 

OK I'll do that.

#200425
Jan 11, 2019 13:16
Vote:
 

@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?

#200432
Jan 11, 2019 16:00
Vote:
 

Yes. Perhaps you want to turn debug mode on 

#200433
Jan 11, 2019 16:23
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.