6

I have upgraded my Sitecore solution from 7.5 to 8.1 update 1. When trying to rebuild the Reporting database, I am getting the following error in the log files:

7084 2016:12:18 05:26:24 ERROR Exception when executing agent aggregation/rebuildAgent
Exception: System.InvalidOperationException
Message: Cannot initialize when there is work to do
Source: Sitecore.Kernel
   at Sitecore.Diagnostics.Assert.IsFalse(Boolean condition, String message)
   at Sitecore.Analytics.RangeScheduler.MongoDbRangeMap.Initialize(Guid left, Guid right, Int64 count)
   at Sitecore.Analytics.Automation.Aggregation.Data.Processing.AutomationHistoryAggregatorManager.Start(List`1 targetProvidersConfigPaths)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Sitecore.Analytics.Aggregation.History.ReportingStorageManager.ProcessRebuild()
   at Sitecore.Analytics.Core.BackgroundService.Run()

Any ideas how to solve this?

1 Answer 1

4

This error means there is some unfinished work remaining from previous rebuilds or other data processing operations. There are two ways to fix this:

Cautious approach

The cleanest way is to investigate your logs for errors that prevent the work from being completed. If you find anything, please create a separate question, since it'll be about a concrete data processing issue in your solution.

Once you fix the issues, the work will be finished and you'll be able to run a Reporting DB rebuild.

Radical approach

If you can't find any issues with data processing, or if don't care about any unfinished data processing work -

  1. Back up the MongoDB database corresponding to the analytics connection string in your ConnectionStrings.config.
  2. Drop the RangeMaps collection if it exists:

    • If you have a standalone database instance, just call this command:

      db.RangeMaps.drop()
      
    • If the RangeMaps collection is sharded, you'll need to unshard it before dropping.

  3. Drop all Range_* collections in the same way as you dropped RangeMaps.
  4. Drop the AutomationRanges collection.
  5. Drop the HistoryTasks collection.
3
  • I can't find the collection "RangeMaps" would you please provide more information about this collection. Commented Dec 18, 2016 at 21:13
  • @MohammedSyam Also, drop Range_* collections. I've updated my answer. Commented Dec 19, 2016 at 7:31
  • Something to add I cleared the records in "HistoryTasks" to be able to run the rebuild process. Commented Dec 21, 2016 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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