Sunday 8 January 2017

Sitecore CD server went down - Exception- Tracker.Current is not initialized


Day before yesterday our one of the CD server went down with plenty of below exceptions


2108 03:18:13 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.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(Guid id)
   at Sitecore.Analytics.Pipelines.EnsureSessionContext.LoadContact.Process(InitializeTrackerArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs 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()

We did an iisreset which fixed the issue. We also reported the incident to Sitecore support to find the root cause . They confirmed it as a sitecore knwon issue and asked us to apply the patch following the below article

 https://kb.sitecore.net/articles/032518

The issue is related to the following method:

Sitecore.Analytics.Model.Framework.ModelFactory.GetConcreteType(Type elementType)
The above method use the "private static readonly IDictionary<Type, Type> typeMap;" internal class field which is initialized in static constructor as "Dictionary" collection:
static ModelFactory()
{
    typeMap = new Dictionary<Type, Type>();
}
However, since the above class is used from different threads the type of the collection, the patch replaces it with ConcurrentDictionary for correct threads synchronization.

No comments:

Post a Comment