Sitecore.Analytics.Exceptions.ContactLockException while merging contacts

1.9k Views Asked by At

I am using Sitecore 8.0 update 5, While I try to Identify the contact using

Tracker.Current.Session.Identify(userKey);

I get the error

Sitecore.Analytics.Exceptions.ContactLockException

Adding the whole stack trace below

Exception: Sitecore.Analytics.Exceptions.ContactLockException
Message: Contact 1cd840a6-f367-4b5f-9df1-74240a03fd29 could not be locked in the XDB.
Source: Sitecore.Analytics
   at Sitecore.Analytics.Tracking.StandardSession.Identify(String userName)
   at Test.Client.Common.Utilities.AnalyticsHelper.MergeContacts(String userKey)
2

There are 2 best solutions below

0
On

This seems to be an issue with your MongoDB. Check if it's running and if it's reachable to your IIS machine. Also check your log for Mongo erros.

Here is a similar issue: https://community.sitecore.net/developers/f/8/t/1771

0
On

This is code from Brain's Pedersen.

// THIS IS BAD!!!
// The user could be extranet\anonymous
if (!Tracker.IsActive)
  return;
Tracker.Current.Session.Identify(Sitecore.Context.User.Name);

// THIS COULD BE A SOLUTION:
if (!Tracker.IsActive)
  return;
if (Sitecore.Current.User.Name.ToLower() == "extranet\\anonymous")
  return;
Tracker.Current.Session.Identify(Sitecore.Context.User.Name);

// OR MAYBE THIS?
if (!Tracker.IsActive)
  return;
if (!Sitecore.Context.User.IsAuthenticated)
  return;
Tracker.Current.Session.Identify(Sitecore.Context.User.Name);

You can go through the link for more details. https://briancaos.wordpress.com/2015/07/02/sitecore-8-and-tracker-current-session-identify-overriding-expired-contact-session-lock-for-contact-id/