9

I am facing the following error:

ERROR Cannot create tracker. Exception: System.IndexOutOfRangeException Message: Index was outside the bounds of the array. Source: mscorlib at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at Sitecore.Analytics.Model.Framework.ModelFactory.GetConcreteType(Type elementType) at Sitecore.Analytics.Model.Framework.ModelFactory.CreateElement(Type elementType) at Sitecore.Analytics.Model.Framework.ModelFactory.CreateFacet(Type facetType) at Sitecore.Analytics.Model.Framework.Faceted.AddFacet(String name, Type type) at Sitecore.Analytics.Model.Framework.ModelFactory.CreateContact(ID id, IReadOnlyDictionary`2 facets) at Sitecore.Analytics.Data.ContactFactory.Create(ID id) at Sitecore.Analytics.Data.ContactRepository.CreateContact(ID id) at Sitecore.Analytics.Pipelines.EnsureSessionContext.LoadContact.Process(InitializeTrackerArgs args) at (Object , Object[] ) at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at Sitecore.Analytics.Pipelines.EnsureSessionContext.EnsureSessionContextPipeline.Run(InitializeTrackerArgs args) at Sitecore.Analytics.DefaultTracker.EnsureSessionContext() at Sitecore.Analytics.Pipelines.CreateTracker.GetTracker.Process(CreateTrackerArgs args) at (Object , Object[] ) at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at Sitecore.Analytics.Tracker.Initialize()

Per this post I verified that we have those config values present in our solution.

Still, randomly I get this error on one of the CD servers and not on all. Any idea why?

  • Can you tell us a little more about your solution? E.g. Sitecore version, infrastructure/roles (dedicated Reporting, Aggregation, CM, CD, xDB Cloud, etc.), etc. – Zachary Kniebel Dec 29 '16 at 16:05
  • Sure @ZacharyKniebel, My solution have CM, CD1, CD2 and it is on perm basis XDB and not in cloud, We have load balanced Mongo and we use SOLR load balanced as well. SC version 8.1 Update 2 – Mrunal Daftari Dec 29 '16 at 16:25
9

This is a known bug in Sitecore. Use this fix to solve the issue.

To track the status of this bug with Sitecore Support, you can use the reference number 95735.

Explanation

The ModelFactory class uses a static dictionary under the cover. It stores a mapping of model interfaces to their implementation types, as defined in the configuration (see Sitecore.Analytics.Model.config). This dictionary is purely an optimization—it helps not to read the configuration every time.

public static class ModelFactory
{
    private static readonly IDictionary<Type, Type> typeMap = new Dictionary<Type, Type>();

    // ...
}

Since this dictionary is static, it can be accessed by several threads simultaneously. The Dictionary class is not meant to be used concurrently, which is why its Insert method throws the obscure error you're seeing. This happens when two threads insert a new entry at the same time.

This should be fixed by either respecting concurrency in the ModelFactory class (e.g. apply locks), or by using a ConcurrentDictionary instead. The fix I linked at the top substitutes the dictionary with a concurrent dictionary.

  • yes Dmytro you are correct, after posting here i reached out to sitecore for help and they pointed me to the same link and we are going to apply the patch. thanks for your help – Mrunal Daftari Jan 3 '17 at 15:04
  • this is the fix per sitecore and as explained above by @dmytro kb.sitecore.net/articles/032518 – Mrunal Daftari Jan 3 '17 at 15:07
  • 1
    @MrunalDaftari - please accept the answer given if it turns out to be correct. Adding a new answer stating what is already stated here, does not add any value. – Mark Cassidy Jan 3 '17 at 15:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.