Device Detection initialization fails with "Could not initialize 51Degrees provider for database" error


Description

The process of aggregation analytics data might get stuck and Experience Analytics reports will not be populated. The issue occurs due to the corrupted DeviceDetectionDB database file that leads to stopping aggregation on Processing instance. The following warning message can be found in log files on the Processing instance:

7436 02:30:08 WARN  Could not initialize 51Degrees provider for database '{your_website_root}\App_Data\DeviceDetection\DeviceDetection{XX-XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}.db'
Exception: System.IO.EndOfStreamException
Message: Unable to read beyond the end of the stream.
Source: mscorlib
at System.IO.__Error.EndOfFile()
at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
at System.IO.BinaryReader.ReadInt32()
at FiftyOne.Foundation.Mobile.Detection.Factories.RootNodeFactory.Create(DataSet dataSet, Int32 index, Reader reader)
at FiftyOne.Foundation.Mobile.Detection.Entities.Memory.MemoryFixedList`2.Read(Reader reader)
at FiftyOne.Foundation.Mobile.Detection.DataSetBuilder.LoadForStreaming(IndirectDataSet dataSet, Dictionary`2 cacheConfiguration)
at FiftyOne.Foundation.Mobile.Detection.DataSetBuilder.BuildFromFile.Build(String filename)
at FiftyOne.Foundation.Mobile.Detection.Factories.StreamFactory.Create(String filePath, DateTime lastModified, Boolean isTempFile)
at Sitecore.CES.DeviceDetection.Providers.FiftyOneDegrees.ProviderFactory.CreateFromDatabase(String databasePath)
at Sitecore.CES.DeviceDetection.Providers.FiftyOneDegrees.DeviceInformationProvider51Degree.InitializeDatabase(String databaseFilePath)

Solution

As a solution, consider the following steps:

  1. Remove content from the following folder:
    {your_website_root}\App_Data\DeviceDetection
  2. Restart your Processing instance.