Error when saving a contact to xDB

Posted by

The following error can occur in Sitecore XP log files while saving a contact to xDB:

ERROR General error when submitting contact.
Exception: Sitecore.XConnect.Operations.FacetOperationException
Message: Operation #0, AlreadyExists, <ContactId>, Classification
Source: Sitecore.Xdb.Common.Web

Or you can see error like this:

Sitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact
[TIMESTAMP_VALUE] [Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception
Sitecore.XConnect.Operations.FacetOperationException: Operation #1, ReferenceNotFound, Contact, Classification
[TIMESTAMP_VALUE] [Error] Sitecore.XConnect.Operations.AddContactOperation: Sitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact
[TIMESTAMP_VALUE] [Error] Sitecore.XConnect.Operations.SetFacetOperation`1[Sitecore.XConnect.Facet]: Sitecore.XConnect.Operations.FacetOperationException: Operation #1, ReferenceNotFound, Contact, Classification

If you checked your shared session state settings and if you’re not doing anything with saving contacts or facets in your code (or you’re sure that your code is handling all cases correctly) there is a fix that Sitecore published for this. You can find it on following address:

https://kb.sitecore.net/articles/397292

Following versions of Sitecore are affected:

  • Sitecore XP 9.0 rev. 171219 (Update-1)
  • Sitecore XP 9.0 rev. 180604 (Update-2)
  • Sitecore XP 9.1 rev. 001564 (Initial Release)
  • Sitecore XP 9.1 rev. 002459 (Update-1)

Fix:

  • Extract the patch package (it’s an update package for Sitecore)
    • For env. with multiple nodes you will need to upload DLL’s manually or via deployment pipeline to all CM’s and CD’s
  • In ‘changedfiles’ folder you will find 2 DLL’s:
    • Sitecore.Analytics.dll
    • Sitecore.Analytics.XConnect.dll
  • Confirm the DLL by:
    • Right click on DLL -> Properties
    • Details
    • You should see Patch details
  • Upload both of DLL’s to bin folder of every CM and CD service in your application
    • If you are using Azure and App Services, upload the to the bin folder on the App Service via ex. App Service Editor; or if you have deployment pipeline do it via pipeline
    • If you are using VM’s procedure is same, upload both files to bin folder
  • Restart the App Service/App Pool
  • Monitor your logs for a minimum of couple of days!
  • Check if Experience Profile works and if Analytics is tracking all the data you have setuped!