Search code examples
dynamics-crmexchange-serverexchangewebservicesserver-side-sync

Exchange and CRM contact duplication 500,000 contacts created


There are 2 issues here,

One is resolved but I still don't know what caused it, and the other is a side-effect

I created one contact in dynamics CRM 2013, there was nothing special about the process, it was the same as always, also note the contact forms have no custom plugins or workflows its standard with a few extra fields,

Then yesterday (03-April-15) I get I call from a user with a screenshot of here contacts in outlook and my newly created contact is there, thousands of copies of it,

So I check in CRM, when I search I get an error back saying to many results to display, so I check directly in the DB I have 498,564 copies of the contact,

So first I set a CRM bulk delete task off, this takes 12 hours to complete, but clears the mess up in CRM,

The Async server log files are full of the following

Crm Exception: Message: Cannot insert duplicate key., ErrorCode: -2147220937, InnerException: Microsoft.Crm.BusinessEntities.CrmDuplicateRecordException: Cannot insert duplicate key. at Microsoft.Crm.BusinessEntities.BusinessProcessObject.DbCreate(IBusinessEntity entity, ExecutionContext context) at Microsoft.Crm.BusinessEntities.BusinessProcessObject.DoCreate(IBusinessEntity entity, ExecutionContext context) [2015-04-02 01:57:38.950] Process:CrmAsyncService |Organization:3752a286-0922-e411-80e2-00505693281b |Thread: 105 |Category: Platform |User: 9af6ba29-6522-4900-9235-61db6f0ca810 |Level: Error |ReqId: a2c4d9df-8cf6-44e8-a93a-690e847b6580 | MessageProcessor.Execute ilOffset = 0x1C5

MessageProcessor fail to process message 'Create' for 'exchangesyncidmapping'. [2015-04-02 01:57:38.982] Process:CrmAsyncService |Organization:3752a286-0922-e411-80e2-00505693281b |Thread: 105 |Category: Platform.Sql |User: 9af6ba29-6522-4900-9235-61db6f0ca810 |Level: Error |ReqId: a2c4d9df-8cf6-44e8-a93a-690e847b6580 | BusinessProcessObject.ExecuteNonQuery ilOffset = 0x34

Exception when executing non-query: insert into [ExchangeSyncIdMappingBase]([ObjectId], [ToCrmChangeType], [LastSyncErrorCode], [IsUnlinkedInCRM], [FromCrmChangeType], [ExchangeEntryId], [OwnerIdType], [IsDeletedInExchange], [ObjectTypeCode], [UserDecision], [Retries], [ExchangeSyncIdmappingId], [OwnerId], [OwningBusinessUnit]) values ('6efce4a2-5bd5-e411-8101-00505693281e', 0, 0, 0, 0, 'AAMkADIxNjdlMmIyLTM1MTctNGM5Ny1hMjUzLTJkNmYwNDVhZGJhZQBGAAAAAABTsYsrMJx3TJCdfGJteVkFBwBkWoS7TTKcR6FU7CToX++gAAAAorXRAABkWoS7TTKcR6FU7CToX++gAAAEKU86AAA=', 8, 0, 2, -1, -1, 'f2d412de-cad8-e411-8101-00505693281e', 'bdc484ff-cebc-e411-80f6-00505693281b', '7f7cda54-6e71-e411-80ee-00505693281b') Exception: System.Data.SqlClient.SqlException (0x80131904): Cannot insert duplicate key row in object 'dbo.ExchangeSyncIdMappingBase' with unique index 'ndx_uniqueobjectidmapping'. The duplicate key value is (6efce4a2-5bd5-e411-8101-00505693281e, bdc484ff-cebc-e411-80f6-00505693281b). The statement has been terminated.

However we also use server side sync, so now I have 4 users including myself with a mailbox with 500,000 contracts each, Trying to view them in outlook client kills the outlook client, in OWA I can only delete maybe 200 at a time, so this is going to take way too long to clear up if I have to do it manually.

So my questions Does anyone know what may have caused this in CRM?

Does anyone know how I can quickly remove these contacts?


Solution

  • In the end, I got a EWS sample from the MS website and changed it slightly to delete the contacts the took around 3 days to completely remove them but it worked