Hi Quan, here's the stack trace (I've obfuscated details related to the project iself):
System.AggregateException:
at Mediachase.Data.Provider.TransactionScope.ExecuteActions (Mediachase.DataProvider, Version=14.6.0.0, Culture=neutral, PublicKeyToken=41d2e7a615ba286c)
at Mediachase.Data.Provider.TransactionScope+ThreadStaticTransactionScope.Commit (Mediachase.DataProvider, Version=14.6.0.0, Culture=neutral, PublicKeyToken=41d2e7a615ba286c)
at Mediachase.Data.Provider.TransactionScope.Complete (Mediachase.DataProvider, Version=14.6.0.0, Culture=neutral, PublicKeyToken=41d2e7a615ba286c)
at Mediachase.Commerce.Catalog.Managers.CatalogAssociationManager.SaveCatalogAssociation (Mediachase.Commerce, Version=14.6.0.0, Culture=neutral, PublicKeyToken=6e58b501b34abce3)
at EPiServer.Commerce.Catalog.Linking.AssociationCommitter.Update (EPiServer.Business.Commerce, Version=14.6.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7)
at EPiServer.Commerce.Catalog.Linking.DefaultAssociationRepository.UpdateAssociations (EPiServer.Business.Commerce, Version=14.6.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7)
at Project.PIM.DataImport.AssociationManager.UpdateContentAssociations (Project, Version=2.1.0.116, Culture=neutral, PublicKeyToken=null: D:\a\1\s\Project\PIM\DataImport\AssociationManager.cs:38)
at Project.ScheduledJobs.ImportScheduledJob.RunImport (Project, Version=2.1.0.116, Culture=neutral, PublicKeyToken=null: D:\a\1\s\Project\ScheduledJobs\ImportScheduledJob.cs:205)
Inner exception Microsoft.Data.SqlClient.SqlException handled at Mediachase.Data.Provider.TransactionScope.ExecuteActions:
at Microsoft.Data.SqlClient.SqlConnection.OnError (Microsoft.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning (Microsoft.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.TdsParser.TryRun (Microsoft.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader (Microsoft.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds (Microsoft.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader (Microsoft.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery (Microsoft.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery (Microsoft.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute (EPiServer.Data, Version=12.9.3.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7)
at Mediachase.Data.Provider.SqlDataProvider.ExecuteNonExec (Mediachase.SqlDataProvider, Version=14.6.0.0, Culture=neutral, PublicKeyToken=41d2e7a615ba286c)
at Mediachase.Commerce.CatalogItemChangeManager.InsertChanges (Mediachase.Commerce, Version=14.6.0.0, Culture=neutral, PublicKeyToken=6e58b501b34abce3)
at Mediachase.Data.Provider.TransactionScope.ExecuteActions (Mediachase.DataProvider, Version=14.6.0.0, Culture=neutral, PublicKeyToken=41d2e7a615ba286c)
BTW - I'm wondering if I could temporary disable content of CatalogItemChange_Insert stored procedure as a workaround?
Would you be able to desribe for what the CatalogItemChange table is used? I cannot seem to find any relevant information, especially in context of Commerce 14
If you are not using the Search Provider (lucene etc.), and if you are not even using the event-driven indexing, you can disable it entirely by setting DisableCatalogEventDrivenIndexing to true inside your ConfigureContainer(ServiceConfigurationContext context)
context.Services.BuildServiceProvider().GetInstance<CatalogOptions>().DisableCatalogEventDrivenIndexing = true;
We are using the LuceneSearchProvider, however the flag DisableCatalogEventDrivenIndexing doesn't seem to affect the code that we're discussing as it only affects CatalogItemChangeForEventDrivenIndexing but not CatalogItemChangeManager.
I created bug COM-16517, but it will take a while to be prioritized. Looking at the code, i think you can empty out the SP as a temporary measure, IF you are not using Personalization
Hi Quan, thank you for the response and the ticket to track.
Would you able to tell how disabling the SP affect the personalization?
I've did in fact disable the SP, because I had no other choice in that matter, I had to make the import of products reliable again.
We're using the personalization, but not in for Commerce product (i.e. only for CMS blocks and only on CMS pages, not Commerce).
I think you can just make it empty. I.e. Comment everything between begin and end
I know how to disable the stored procedure :)
But my previous questions still stands - you've metioned that it has some impact on personalization - how does the disabling of stored procedure will affect personalization?
No I mixed things up - my bad. CatalogItemChangeManager is not used for recommendation, that's its sister. CatalogItemChangeManager is used so you can build the index incrementally, as you are using LuceneSearchProvider you'll be needing it (unless you rebuild index all the time)
What does your CatalogItemChange_Insert look like before your modification?
Okey, that's fine - as long it only affects the Lucene Search, then it's fine.
The content of unmodified CatalogItemChange_Insert:
CREATE PROCEDURE [dbo].[CatalogItemChange_Insert]
@EntryIds [udttIdTable] READONLY
AS
BEGIN
MERGE INTO CatalogItemChange AS TARGET
USING (SELECT
C.ID, CE.CatalogId
FROM @EntryIds C
INNER JOIN CatalogEntry CE ON c.ID = CE.CatalogEntryId)
AS SOURCE (CatalogEntryId, CatalogId)
ON
TARGET.CatalogEntryId = SOURCE.CatalogEntryId
AND TARGET.CatalogId = SOURCE.CatalogId
AND TARGET.IsBeingIndexed = 0
WHEN NOT MATCHED BY TARGET THEN
INSERT (CatalogEntryId, CatalogId, IsBeingIndexed) VALUES (CatalogEntryId, CatalogId, 0);
END
GO
In our project we have an automated process importing products with relationship between them.
As one of the last steps we're creating bulk associations and saving them via IAssociationRepository.UpdateAssociations.
However, it seems to be randomly throwing exceptions:
It doesn't seem to follow any pattern and when the process is reinitated, it pops-up for different catalogs or products.
I've seen simillar threads from the past, but it doesn't seem the solutions (upgrade to later version) are applicable to Commerce 14.
https://world.optimizely.com/forum/developer-forum/Commerce/Thread-Container/2018/7/import-products-over-service-api-fail-in-production-environment-only/
https://world.optimizely.com/forum/developer-forum/Commerce/Thread-Container/2019/5/primary-key-violation-error-with-sp-catalogitemchange_insert/