"Index was out of range" error while rebuilding Reporting database


Description

System.ArgumentOutOfRangeException may be thrown during analytics aggregation or while rebuilding the Reporting database. This happens because highly engaged campaigns might have an incorrect index due to the corrupted interaction in the Email Experience Manage (EXM) aggregation. The following error can be found in the log:

ERROR [Experience Analytics]: SegmentProcessor failed to process interaction '56f2c763-43db-4224-9ca7-1530d50445cb' segment '0c385039-b63a-4ee0-afad-3d2bc4870f81' - 
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at Sitecore.EmailCampaign.ExperienceAnalytics.Dimensions.ExmDimensionBase.<getclickeventdata>d__6.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Sitecore.EmailCampaign.ExperienceAnalytics.Dimensions.ExmDimensionBase.GetData(IVisitAggregationContext context)
   at Sitecore.ExperienceAnalytics.Aggregation.Data.Model.AggregationSegment.GetData(IVisitAggregationContext context)
   at Sitecore.ExperienceAnalytics.Aggregation.Pipeline.SegmentProcessor.ProcessSegments(AggregationPipelineArgs args, IEnumerable`1 segments)</getclickeventdata>
This issue affects EXM 3.4 version.

Solution

To resolve the issue, consider one of the following options: