Configure the Solr retry strategy

Abstract

Explains how to configure a retry strategy for Solr.

You can configure Solr to retry an operation if the first attempt to run the operation fails. This is useful if you experience transient errors, such as network problems, or you have Solr availability issues.

Enable a retryer strategy

You configure the strategy to use in the solrRetryer section of the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file.

To enable a retryer strategy:

• Create a configuration include file that overrides the solrRetryer node.

There are three different strategies you can enable:

• NoRetryRetryer: this is the default strategy. It never retries. You configure it like this:

<solrRetryer type="Sitecore.ContentSearch.SolrProvider.Availability.Retryer.NoRetryRetryer, Sitecore.ContentSearch.SolrProvider" singleInstance="true" />
• FixedIntervalsRetryer: this strategy retries in fixed intervals that you specify.

For example, with the following configuration, Solr retries three times (in addition to the first try). The first attempt is after one second, the second attempt after two seconds, and the third attempt after three seconds:

<solrRetryer type="Sitecore.ContentSearch.SolrProvider.Availability.Retryer.FixedIntervalsRetryer, Sitecore.ContentSearch.SolrProvider" singleInstance="true" >
<interval>00:00:01</interval>
<interval>00:00:02</interval>
<interval>00:00:03</interval>
</sleepDurations>
</solrRetryer>
• ExponentialRetryer: this strategy retries using an exponential backoff algorithm. You enable and configure the strategy this way:

<solrRetryer type="Sitecore.ContentSearch.SolrProvider.Availability.Retryer.ExponentialRetryer, Sitecore.ContentSearch.SolrProvider" singleInstance="true">
<param desc="retryCount">3</param>
<param desc="deltaBackoff">00:00:01</param>
<param desc="maxBackoff">00:00:05</param>
<param desc="minBackoff">00:00:01</param>
</solrRetryer>

Create a custom retryer

You can implement a custom retryer if none of the other strategies suit you.

To create a custom retryer:

1. Create a class that inherits the Sitecore.ContentSearch.SolrProvider.Availability.Retryer.BaseRetryer class.

2. Implement the methods you need.

3. Enable the custom retryer in the solrRetryer section of the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file.