We have currently enabled the Sitecore OOB Personalization module, and have developed some custom conditions and actions to display a particular component on the website.
When a user authenticated on the sire, we are identifying the contact with a primary key, such that all interaction the user has done is associated with the primary key in the Mongo DB database later on.
Following activation of the Personalization module on our Production environment(which is a load-balanced environment), the component was working fine during testing. Yet, after some time we noticed that the component was not being displayed on a few individual servers. When we cleared the HTML cache on these specific servers, the component was working as required for some time but got hidden again afterward.
It was a random behavior that was happening with this component on different servers, and not on specific individual servers(there is no HTML cache enabled on the MVC rendering for the component).
In our logs, we noticed that the following errors were being obtained a few times on those individual servers
Exception: Sitecore.Analytics.Exceptions.ContactLockException Message:
Failed to extend contact lease for contact f217ae9d-a38f-4752-be0c-d824965f4d3b
Source: Sitecore.Analytics at Sitecore.Analytics.Tracking.ContactManager.SaveAndReleaseContact(Contact contact) at Sitecore.Analytics.Pipelines.EndAnalytics.ReleaseContact.Process(PipelineArgs args) at (Object , Object[] ) at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, Boolean failIfNotExists)
at Sitecore.Analytics.Pipelines.HttpRequest.EndAnalytics.Process(HttpRequestArgs args)
Following the occurrence of this error on the server, we noticed that one of the following conditions was being set as true
if (Sitecore.Analytics.Tracking.Profile != null &&
Sitecore.Analytics.Tracking.Profile.Count > 0)
for all contacts who were trying to access the site(noticed these in the logs when accessing the individual server where the component was not being displayed).
Can you indicate in which specific use case we get this type of issue?
You may find below the code snippet we have for the identification of the contact(the variable urn is our primary key)
ContactManager contactManager = Factory.CreateObject("tracking/contactManager", true) as ContactManager;
if (contactManager != null)
{
Contact contact1 = contactManager.LoadContactReadOnly(urn);
if (contact1 == null || contact1.ContactId == Guid.Empty)
Tracker.Current.Session.Identify(urn);
else
{
ContactRepository contactRepository = Sitecore.Configuration.Factory.CreateObject("tracking/contactRepository", true) as ContactRepository;
if (contactRepository != null)
{
Contact newContact = contactRepository.CreateContact(ID.NewID);
contact1.IsTemporaryInstance = true;
newContact.Identifiers.IdentificationLevel = ContactIdentificationLevel.Known;
newContact.Identifiers.Identifier = urn;
contactRepository.MergeContacts(newContact, contact1);
}
}
}