0121 31 45 374
Qoute Icon

Error running Ucommerce scratch indexer Illegal duplicate key definitions

Tim

We hit an interesting issue indexing the Ucommerce data the other day which had us going for a while.

It turns out that when upgrading Ucommerce to 7.0.6, some new payment providers were added to `uCommerce_Definition` with duplicate Guids which then caused an issue. We found it by searching the database for the value `c94644e4-f213-48a6-98eb-741aca16155f`.

In our instance it was

Id Name
4 Adyen
9 eWAY
19 Ideal (Ing Bank)
21 Schibsted

The fix was to remove this duplicate. If you want to _just update_ the data you can run this (assuming the ids are the same!):

UPDATE uCommerce_Definition 
SET Guid=NEWID() 
WHERE DefinitionId IN (4,9,19,21)

It would probably be worth checking your data though as I suspect the Guids will be different so you can find these using this:

SELECT * 
FROM uCommerce_Definition d 
WHERE EXISTS(
    SELECT * 
    FROM uCommerce_Definition id 
    WHERE id.Guid=d.Guid AND id.DefinitionId<>d.DefinitionId
)

The error it threw was when indexing/scratch indexing and it looks like this: the key bit is after the `/` i.e. in `definitions/c94644e4-f213-48a6-98eb-741aca16155f`, `c94644e4-f213-48a6-98eb-741aca16155f` is the Guid you need to look for.

System.AggregateException: One or more errors occurred. ---> Raven.Abstractions.Exceptions.ConcurrencyException: Illegal duplicate key definitions/c94644e4-f213-48a6-98eb-741aca16155f ---> Microsoft.Isam.Esent.Interop.EsentKeyDuplicateException: Illegal duplicate key
   at Microsoft.Isam.Esent.Interop.Api.JetUpdate(JET_SESID sesid, JET_TABLEID tableid, Byte[] bookmark, Int32 bookmarkSize, Int32& actualBookmarkSize)
   at Microsoft.Isam.Esent.Interop.Update.Save(Byte[] bookmark, Int32 bookmarkSize, Int32& actualBookmarkSize)
   at Raven.Storage.Esent.StorageActions.DocumentStorageActions.InsertDocument(String key, RavenJObject data, RavenJObject metadata, Boolean overwriteExisting)
   --- End of inner exception stack trace ---
   at Raven.Storage.Esent.StorageActions.DocumentStorageActions.InsertDocument(String key, RavenJObject data, RavenJObject metadata, Boolean overwriteExisting)
   at Raven.Database.Actions.DocumentActions.<>c__DisplayClass1c.b__17(IStorageActionsAccessor accessor)
   at Raven.Storage.Esent.TransactionalStorage.ExecuteBatch(Action`1 action, EsentTransactionContext transactionContext)
   at Raven.Storage.Esent.TransactionalStorage.Batch(Action`1 action)
   at Raven.Database.Actions.DocumentActions.BulkInsert(BulkInsertOptions options, IEnumerable`1 docBatches, Guid operationId, CancellationToken token)
   at Raven.Database.Server.Controllers.BulkInsertController.<>c__DisplayClass6.b__3()

Liked this post? Got a suggestion? Leave a comment