Errors while saving Analytics data if Analytics.ClusterName is not specified


Description

If the Analytics.ClusterName setting is not specified in the Sitecore.Analytics.Tracking.config file, the following exception may occur in the log files of the content delivery servers:

ERROR General error when submitting contact.
Exception: System.InvalidOperationException
Message: A contact is locked by another operation.
Source: Sitecore.Analytics.MongoDB
at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbContactStorage.LoadContactIdentifier(ID contactId, LeaseOwner leaseOwner)
at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider.ObsoleteContact(ID contactId, LeaseOwner leaseOwner, ID successorId)
at Sitecore.Analytics.Data.ContactRepository.SaveContact(Contact contact, ContactSaveOptions options)
at Sitecore.Analytics.Tracking.ContactManager.SubmitContact(Contact contact, ContactSaveOptions options)

Solution

To resolve the issue, follow the steps below for all Content Delivery servers:

  1. Open the /App_Config/Include/Sitecore.Analytics.Tracking.config file.
  2. Set the value of the Analytics.ClusterName setting to the host name of your site (for a single server setup), or to the host name of the load balancer in front of the cluster (for a clustered environment):
    <setting name="Analytics.ClusterName" value="yoursite.net" />
    Note: in case of a clustered environment, all Content Management Sitecore instances should be able to establish HTTP connections to the cluster without any authentication (cookie-based, basic, federated etc.). If the cluster only accepts HTTPS connections or redirects all HTTP requests to corresponding HTTPS ones, the Analytics.ClusterName setting value must include HTTPS schema:
    <setting name="Analytics.ClusterName" value="https://yoursite.net" />