2

When I try to identify the current contact via a uniqke key request parameter:

Tracker.Current.CurrentPage.Session.Identify(Page.Request.QueryString["uniquekey"]);

I get the following exception:

940 15:07:33 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.SaveContactWithIdentifier(IContact contact, ContactSaveOptions saveOptions)
   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider.<>c__DisplayClass9.<SaveContact>b__7()
   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider.Try(Action action)
   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider.SaveContact(IContact contact, ContactSaveOptions saveOptions)
   at Sitecore.Analytics.Data.ContactRepository.SaveContact(Contact contact, ContactSaveOptions options)
   at Sitecore.Analytics.Tracking.ContactManager.SubmitContact(Contact contact, ContactSaveOptions options)

What can I do to solve this problem? Or is there a workaround?

Thank you and kind regards.

4

1 回答 1

2

Why this happens

Normally, you will see this error when you forget to set Analytics.ClusterName in the configuration file Sitecore.Analytics.Tracking.config. This becomes a problem because in the beginning of every session Sitecore lock the current contact by creating a Lease in xDB. It uses Analytics.ClusterName as the identifier of the lock.

The error you are seeing occurs because your Sitecore instance doesn't realize that it owns the lease on the contact since the lease owner identifier is missing.

If you look at your contact in the collection database, you are likely to see something like this:

enter image description here

As you can see, the Owner document does not have the Identifier field set. This indicates that the entity that created the lease did not provide an identifier (its value was an empty string or null).

Solution

To solve this in a development environment, just set both Analytics.ClusterName and Analytics.HostName setting values to the local domain name you're using when accessing the application, e.g. sitecore.

<setting name="Analytics.ClusterName" value="sitecore" />
<setting name="Analytics.HostName" value="sitecore" />

You can read more about these settings here.

UPDATE: Sitecore has added a knowledge base article about this issue: https://kb.sitecore.net/articles/965127

于 2015-10-20T11:31:41.703 回答