We had a customer's website (Sitecore 8.2 on Azure) go down last week for about 20 minutes. The site was so locked up that there were no Sitecore log messages. However, there were a bunch of messages in the Windows Event Log that said, “Tracker.Current is not initialized”. Eventually that got me thinking of MongoDB, and I was pretty sure I knew the issue. The why, though, still escapes me.

That day I was installing the xDB Data Migration Tool to tracking data from Mongo to SQL as part of a 9.2 upgrade. One of the steps reads as follows:

The xDB Data Migration Tool reads virtually all of the data in the MongoDB data for analytics from Sitecore 8.x. For the tool to do this eɝcientO\, you must add a couple of indexes. NOTE Adding these indexes is optional. However, if you choose not to add these indexes, you should expect the data migration process to take longer to complete. To add indexes to MongoDB collections:

  1. Open a mongo shell.

  2. Select the database with the xDB data that you plan to migrate to Sitecore 9.2.

  3. Enter the following commands: >db.getCollection('Devices').createIndex({LastKnownContactId:1}) db.getCollection('Interactions').createIndex({ContactId:1})

It seems Mongo locks the entire database when you’re indexing (thanks for the warning, Sitecore documentation!). So what we think happened was the database locked, Tracker.Current couldn’t initialize, and the site locked up completely.

The client pushed back on that, saying, “I had always thought MongoDB was a completely separate component of the overall solution, where the web traffic was being sent and stored for further analysis. Are you saying the creation of an index on the MongoDB locked up the MongoDB database, which in turn locked up the entire Sitecore system? ”. And now that I think of it, that’s pretty cromulent. Sitecore can’t be that tightly coupled with Mongo, can it?

I checked out where Tracker.Current is used in the site, and it’s only in 2 locations. One just logs search data, but the other is in the shared layout and executes on every request. It’s not doing much, though:

   if (Tracker.Current.Contact == null || cookieValue.Length > 1) {
                    return contactId;

So I’m beginning to wonder I’m barking up the wrong tree, and put on my hair shirt in error. I wish I had a big sample Mongo database to experiment with.

What do you folks think? Can you think of a path where a locked up MongoDB could cause the site to lock up?

Oh, and if you’re ever installing the xDB data migration tool, don’t blindly copy and paste the queries they give you into Mongo. Specifically, add {background: true} to the query to avoid a lock.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.