Handle transient database connection errors


Handle transient database connection errors with smart retry functionality.

In a cloud environment, such as Azure, database connections can drop periodically. You can recognize such transient errors and automatically retry an operation that failed, instead of showing an error message to the user. Most operations succeed on a second try, and the user will not know there was an error.

The Sitecore.Data.DataProviders.TransientRetryer is based on the Microsoft Enterprise Library Transient Fault Handling Application Block and it implements retry logic. The retryer specifies an incremental retry strategy where it waits one second before the first retry, and then retries up to three times. The transient retryer is disabled by default.

To enable the transient retryer:

  • Patch the sitecore.config file like this:

    <retryer disabled="false" type="Sitecore.Data.DataProviders.TransientRetryer, Sitecore.Kernel">
         <param desc="Log each exception">true</param>

There is another, older retryer as well (Sitecore.Data.DataProviders.Retryer). If you enable both retryers, the one defined last in the configuration will be used. Therefore, we recommend you only use the transient retryer.