Lately, we've been seeing this error showing up quite extensively in our logs. It only seems to happen for Commerce Content.
We are running Episerver CMS 11.20.2, Episerver CMS UI 11.31.0, Episerver Find 13.3.0 and Episerver Commerce 12.7.2:
2021-01-22 00:52:51,211 [178] ERROR EPiServer.Find.Cms.ContentEventIndexer: An exception occurred while indexing (IContent). The 'RelatedContent' function could not be evaluated for Content: 95161__CatalogContent. An item with the same key has already been added.. EPiServer.Find.Cms.ContentIndexerException: The 'RelatedContent' function could not be evaluated for Content: 95161__CatalogContent. An item with the same key has already been added. ---> System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) at EPiServer.DataAbstraction.ReferenceInformation.CreateReferenceInformation(DataTable data, ILanguageBranchRepository languageBranchRepository, IPermanentLinkMapper permanentLinkMapper) at EPiServer.Core.Internal.DefaultContentProvider.GetReferencesToContentItems(IEnumerable`1 contentLinks) at EPiServer.Core.Internal.DefaultContentRepository.<>c__DisplayClass45_0.<GetReferencesToContent>b__0(ContentProvider p) at EPiServer.Core.ContentProviderMap.Iterate(Action`1 contentProviderHandler) at EPiServer.Core.Internal.DefaultContentRepository.GetReferencesToContent(ContentReference contentLink, IEnumerable`1 descendents, Boolean includeDescendants) at EPiServer.DataFactory.GetReferencesToContent(ContentReference contentLink, Boolean includeDecendents) at EPiServer.Find.Cms.Module.IndexingModule.<RegisterRelatedContentForContentAreaContent>b__34_0(IContent x) at EPiServer.Find.Cms.Conventions.RelatedContentConvention.RelatedContent(IContent content) at EPiServer.Find.Cms.ContentIndexer.RelatedContent(IContent content) --- End of inner exception stack trace --- at EPiServer.Find.Cms.ContentIndexer.RelatedContent(IContent content) at EPiServer.Find.Cms.ContentIndexer.RelatedContentTree(IContent content, IEnumerable`1 traversedContent) at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 contents, IndexOptions options) at EPiServer.Find.Cms.ContentEventIndexer.Index(IEnumerable`1 contentLinks) at EPiServer.Find.Cms.ContentEventIndexer.Sync(IEnumerable`1 contentToIndex, HashSet`1 contentToIndexSet, Func`1 index) at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue(IEnumerable`1 contentToIndex) at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue() EPiServer.Find.Cms.ContentIndexerException: The 'RelatedContent' function could not be evaluated for Content: 95161__CatalogContent. An item with the same key has already been added. ---> System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) at EPiServer.DataAbstraction.ReferenceInformation.CreateReferenceInformation(DataTable data, ILanguageBranchRepository languageBranchRepository, IPermanentLinkMapper permanentLinkMapper) at EPiServer.Core.Internal.DefaultContentProvider.GetReferencesToContentItems(IEnumerable`1 contentLinks) at EPiServer.Core.Internal.DefaultContentRepository.<>c__DisplayClass45_0.<GetReferencesToContent>b__0(ContentProvider p) at EPiServer.Core.ContentProviderMap.Iterate(Action`1 contentProviderHandler) at EPiServer.Core.Internal.DefaultContentRepository.GetReferencesToContent(ContentReference contentLink, IEnumerable`1 descendents, Boolean includeDescendants) at EPiServer.DataFactory.GetReferencesToContent(ContentReference contentLink, Boolean includeDecendents) at EPiServer.Find.Cms.Module.IndexingModule.<RegisterRelatedContentForContentAreaContent>b__34_0(IContent x) at EPiServer.Find.Cms.Conventions.RelatedContentConvention.RelatedContent(IContent content) at EPiServer.Find.Cms.ContentIndexer.RelatedContent(IContent content) --- End of inner exception stack trace --- at EPiServer.Find.Cms.ContentIndexer.RelatedContent(IContent content) at EPiServer.Find.Cms.ContentIndexer.RelatedContentTree(IContent content, IEnumerable`1 traversedContent) at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 contents, IndexOptions options) at EPiServer.Find.Cms.ContentEventIndexer.Index(IEnumerable`1 contentLinks) at EPiServer.Find.Cms.ContentEventIndexer.Sync(IEnumerable`1 contentToIndex, HashSet`1 contentToIndexSet, Func`1 index) at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue(IEnumerable`1 contentToIndex) at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue()
Lately, we've been seeing this error showing up quite extensively in our logs. It only seems to happen for Commerce Content.
We are running Episerver CMS 11.20.2, Episerver CMS UI 11.31.0, Episerver Find 13.3.0 and Episerver Commerce 12.7.2:
2021-01-22 00:52:51,211 [178] ERROR EPiServer.Find.Cms.ContentEventIndexer: An exception occurred while indexing (IContent). The 'RelatedContent' function could not be evaluated for Content: 95161__CatalogContent. An item with the same key has already been added..
EPiServer.Find.Cms.ContentIndexerException: The 'RelatedContent' function could not be evaluated for Content: 95161__CatalogContent. An item with the same key has already been added. ---> System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at EPiServer.DataAbstraction.ReferenceInformation.CreateReferenceInformation(DataTable data, ILanguageBranchRepository languageBranchRepository, IPermanentLinkMapper permanentLinkMapper)
at EPiServer.Core.Internal.DefaultContentProvider.GetReferencesToContentItems(IEnumerable`1 contentLinks)
at EPiServer.Core.Internal.DefaultContentRepository.<>c__DisplayClass45_0.<GetReferencesToContent>b__0(ContentProvider p)
at EPiServer.Core.ContentProviderMap.Iterate(Action`1 contentProviderHandler)
at EPiServer.Core.Internal.DefaultContentRepository.GetReferencesToContent(ContentReference contentLink, IEnumerable`1 descendents, Boolean includeDescendants)
at EPiServer.DataFactory.GetReferencesToContent(ContentReference contentLink, Boolean includeDecendents)
at EPiServer.Find.Cms.Module.IndexingModule.<RegisterRelatedContentForContentAreaContent>b__34_0(IContent x)
at EPiServer.Find.Cms.Conventions.RelatedContentConvention.RelatedContent(IContent content)
at EPiServer.Find.Cms.ContentIndexer.RelatedContent(IContent content)
--- End of inner exception stack trace ---
at EPiServer.Find.Cms.ContentIndexer.RelatedContent(IContent content)
at EPiServer.Find.Cms.ContentIndexer.RelatedContentTree(IContent content, IEnumerable`1 traversedContent)
at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 contents, IndexOptions options)
at EPiServer.Find.Cms.ContentEventIndexer.Index(IEnumerable`1 contentLinks)
at EPiServer.Find.Cms.ContentEventIndexer.Sync(IEnumerable`1 contentToIndex, HashSet`1 contentToIndexSet, Func`1 index)
at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue(IEnumerable`1 contentToIndex)
at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue()
EPiServer.Find.Cms.ContentIndexerException: The 'RelatedContent' function could not be evaluated for Content: 95161__CatalogContent. An item with the same key has already been added. ---> System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at EPiServer.DataAbstraction.ReferenceInformation.CreateReferenceInformation(DataTable data, ILanguageBranchRepository languageBranchRepository, IPermanentLinkMapper permanentLinkMapper)
at EPiServer.Core.Internal.DefaultContentProvider.GetReferencesToContentItems(IEnumerable`1 contentLinks)
at EPiServer.Core.Internal.DefaultContentRepository.<>c__DisplayClass45_0.<GetReferencesToContent>b__0(ContentProvider p)
at EPiServer.Core.ContentProviderMap.Iterate(Action`1 contentProviderHandler)
at EPiServer.Core.Internal.DefaultContentRepository.GetReferencesToContent(ContentReference contentLink, IEnumerable`1 descendents, Boolean includeDescendants)
at EPiServer.DataFactory.GetReferencesToContent(ContentReference contentLink, Boolean includeDecendents)
at EPiServer.Find.Cms.Module.IndexingModule.<RegisterRelatedContentForContentAreaContent>b__34_0(IContent x)
at EPiServer.Find.Cms.Conventions.RelatedContentConvention.RelatedContent(IContent content)
at EPiServer.Find.Cms.ContentIndexer.RelatedContent(IContent content)
--- End of inner exception stack trace ---
at EPiServer.Find.Cms.ContentIndexer.RelatedContent(IContent content)
at EPiServer.Find.Cms.ContentIndexer.RelatedContentTree(IContent content, IEnumerable`1 traversedContent)
at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 contents, IndexOptions options)
at EPiServer.Find.Cms.ContentEventIndexer.Index(IEnumerable`1 contentLinks)
at EPiServer.Find.Cms.ContentEventIndexer.Sync(IEnumerable`1 contentToIndex, HashSet`1 contentToIndexSet, Func`1 index)
at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue(IEnumerable`1 contentToIndex)
at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue()
Any ideas on why this is happening?