Sitecore-Forms-Extensions icon indicating copy to clipboard operation
Sitecore-Forms-Extensions copied to clipboard

Sitecore.XConnect-Error when saving a contact to xDB

Open YF82 opened this issue 5 years ago • 12 comments

Hi - we notice that xconnect though a lot of exception like sample below , search shows it might be a know issue in xconnect and fixes are provided here https://kb.sitecore.net/articles/397292 , can you please let us know if we can proceed with the fix?

2020-06-15T17:38:06 PID[3520] Error Sitecore.XConnect.Operations.AddContactOperation: Sitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact 2020-06-15T17:38:06 PID[3520] Error Sitecore.XConnect.Operations.SetFacetOperation`1[Sitecore.XConnect.Facet]: Sitecore.XConnect.Operations.FacetOperationException: Operation #1, ReferenceNotFound, Contact, Classification 2020-06-15T17:38:06 PID[3520] Error ["XdbContextLoggingPlugin"] XdbContext Batch Execution ExceptionSitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact 2020-06-15T17:38:06 PID[3520] Error ["XdbContextLoggingPlugin"] XdbContext Batch Execution ExceptionSitecore.XConnect.Operations.FacetOperationException: Operation #1, ReferenceNotFound, Contact, Classification

we have submitted a ticket to sitecore about it and below was there replies

I have reviewed your custom code and found the possible culprit. You have a custom method that utilize the SetFacet() method and update facets for the contact which remains in the session (Feature.FormsExtensions.XDb.Repository.XDbContactRepository.UpdateContactFacet). There can be a situation when the contact hasn't been updated in the session after submitting. When the session ends Sitecore tries to save this contact one more time. As a result, the "AlreadyExists" exceptions are generated because the contact has been already saved to xDB.

Based on this, I suggest you reviewing your code and make sure that the contact is reloaded after submitting:

{

client.Submit();

// Remove contact data from shared session state - contact will be re-loaded // during subsequent request with updated facets manager.RemoveFromSession(Sitecore.Analytics.Tracker.Current.Contact.ContactId); Sitecore.Analytics.Tracker.Current.Session.Contact = manager.LoadContact(Sitecore.Analytics.Tracker.Current.Contact.ContactId);

}

Please consider reading the following article for more information regarding this:

https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/set-contact-facets-in-session.html

The method I have mentioned belongs to the Feature.FormsExtensions.dll assembly that is located in the bin folder of your CD server.

so am trying to validate with your the solution they provided

YF82 avatar Aug 07 '20 16:08 YF82

Hmn, can you help me the case/context in which this occurs?

When fields are stored into xDB via "StoreFieldBindingValues" class, you can see the method xDbService.ReloadContactDataIntoSession(); is called on line 56.

This should already take care of reloading the contact into the session.

bartverdonck avatar Aug 20 '20 12:08 bartverdonck

Hi- @bartverdonck I am in track with the same issue and letting you know that this issue happens in scaled environment.

Lina-ElBadrawy avatar Sep 02 '20 15:09 Lina-ElBadrawy

Hi - so basically we are using the extension for sending mails and recapture controls , the functionality provided are satisfied our need so we did not add any custom development , let me know how i can provide you with more information that can help.

i will reply back to Sitecore ticket with information you provided.

Thanks

YF82 avatar Sep 11 '20 13:09 YF82

I faced this issue too, I think there is a race condition if binding to both the Experience Profile value provider, as well as using Identify Contact save action. It seems to happen for contacts that already have the contact identifier saved, and then come back with a new anonymous session, and then submitting the form again.

markgibbons25 avatar Oct 08 '20 22:10 markgibbons25

Thanks for the info @markgibbons25 . I'll try reproducing.

bartverdonck avatar Nov 02 '20 12:11 bartverdonck

@markgibbons25 I have tried to reproduce this following the scenario you provided. Unfortunatly, I had no succes in reproducing the error. (Tried with test https://cm.sfe.localhost/bugs/bug-89) Any suggestions?

bartverdonck avatar Nov 02 '20 16:11 bartverdonck

Ok I'll try set up a test case

markgibbons25 avatar Nov 02 '20 23:11 markgibbons25

We are experiencing the same. Any news?

AlphaSolutions-jbj avatar Jun 14 '21 12:06 AlphaSolutions-jbj

Still waiting on a reproducable scenario.

bverdonck avatar Jun 17 '21 06:06 bverdonck

I Have a reproduceable scenario and trying everything but still the error remains same, opened a ticket with sitecore and they said you are using the 3rd party module so they cant help here. Please give me some suggestions on this -

[Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception Sitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact [Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception Sitecore.XConnect.Operations.FacetOperationException: Operation #1, ReferenceNotFound, Contact, Emails

nag-abhishek avatar Aug 12 '22 13:08 nag-abhishek

If you have a reproducible scenario then please share it here.

On Fri, 12 Aug 2022, 11:34 pm nag-abhishek, @.***> wrote:

I Have a reproduceable scenario and trying everything but still the error remains same, opened a ticket with sitecore and they said you are using the 3rd party module so they cant help here. Please give me some suggestions on this -

[Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception Sitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact [Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception Sitecore.XConnect.Operations.FacetOperationException: Operation #1 https://github.com/bartverdonck/Sitecore-Forms-Extensions/issues/1, ReferenceNotFound, Contact, Emails

— Reply to this email directly, view it on GitHub https://github.com/bartverdonck/Sitecore-Forms-Extensions/issues/89#issuecomment-1213115604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYQJ5URZKA4KXEBAWTU6F3VYZHGVANCNFSM4PXZEHMQ . You are receiving this because you were assigned.Message ID: @.***>

markgibbons25 avatar Aug 12 '22 21:08 markgibbons25

We are using the send email event and when this event is triggered there is a below exception, and this is working as expected before but the below exception comes without any changes made related to this image

nag-abhishek avatar Aug 16 '22 09:08 nag-abhishek