We’re experiencing problems with mass updating base products/variants in Litium. Different Entity Framework related exceptions are thrown when a large amount of products/variants is handled in one go.
Scenario: we have an import task that imports product data from an XML file and updates the corresponding base products/variants in Litium. The XML file can contain up to ~16000 products. The import task goes through each product in the file and compares the data to the corresponding base product/variant data in Litium. If anything have changed, a writable clone of the base product/variant is created, the affected fields/category connections/etc are changed and the task tries to update the base product/variant. This is when the problem starts occurring.
When the file contains a large amount of products, the calls to baseProductService.Update and variantService.Update starts throwing exceptions for random products/variants. This seems to happen randomly without any obvious pattern to it - different products are affected in different runs. We can re-run the same XML-file twice and get the problem for different products/variants.
All the different exceptions are Entity Framework related. Examples:
- Violation of PRIMARY KEY constraint ‘PK_BaseProductCategoryLinkEntity’. Cannot insert duplicate key in object ‘Products.BaseProductCategoryLink’. The duplicate key value is (da79834f-1f4b-4377-ba1a-b9de39365c07, 27f5c7c3-f4b8-4c48-9471-9235d6144ab7).
- Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
- Violation of PRIMARY KEY constraint ‘PK_Products_VariantFieldData’. Cannot insert duplicate key in object ‘Products.VariantFieldData’. The duplicate key value is (7e39886b-e132-41a3-b467-e593acc96df9, _name, sv-SE, 0)
We do have proper validation in place in the code that should prevent this. If a field hasn’t changed, we don’t try to update it. If a category connection already exists, we don’t try and add another identical one.
We’re at a loss on how to solve this. Anyone else experienced the same kind of problem?
Litium version: 6.2.2