Cleanup Device Detection Databases

Once we faced below error during deployment on one of Content Delivery instance:

Failed to deploy web package to App Service.
Error Code: ERROR_NOT_ENOUGH_DISK_SPACE
More Information: Web Deploy detected insufficient space on disk.
Microsoft.Web.Deployment.DeploymentException: The error code was 0x80070070.
System.IO.IOException: There is not enough space on the disk.

Device Detection- Disk Space

While troubleshooting, one of our DevOps engineer noticed that there were 216 Device Detection Database Files of total 52,988,077,045 bytes in /wwwroot/App_Data/DeviceDetection folder.

Device Detection Databases

We manually deleted old versions of databases at that time and raised Sitecore support ticket.

As per Sitecore,

Device Detection is enabled by default from Sitecore 9.0 and 51Degrees is default provider. New version of database is downloaded to the instance when a user visits site on a device which is not added to the database yet. And old versions of databases are not deleted automatically.

Sitecore provided below workarounds for the issue:

1. Manually delete old versions of databases form /App_Data/DeviceDetection folder.
2. Configure Sitecore.Tasks.CleanupAgent agent to check /App_Data/DeviceDetection folder.

Patch configuration to delete device detection databases which are added 30 days ago. You can configure maxAge as per the frequency of database version creation.

<configuration>
  <sitecore>
    <scheduling>
      <agent type="Sitecore.Tasks.CleanupAgent">
        <files>
          <remove folder="/App_Data/DeviceDetection" pattern="DeviceDetectionDB-*.db" maxAge="30.00:00:00" recursive="false" />
        </files>
      </agent>
    </scheduling>
  </sitecore>
</configuration>

Sitecore has registered this behavior as a bug and the reference number is 328306.

References

https://doc.sitecore.com/developers/90/sitecore-experience-management/en/using-device-detection.html
https://doc.sitecore.com/developers/90/sitecore-experience-management/en/configure-sitecore-device-detection.html
https://labs.tadigital.com/index.php/2018/11/05/device-detection-in-sitecore/

Update:

This has been fixed in Sitecore 9.3 Initial Release – https://kb.sitecore.net/articles/872808
In order to fix this bug, the Sitecore.CES.DeviceDetection.Providers.DeviceDetectionClient class is updated. The CleanUpFiles method has been implemented to delete old files when a new file is uploaded successfully.

2 thoughts on “Cleanup Device Detection Databases

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s