10

We had an issue recently where the Solr search servers went down and it took the site down too.

Is there a way to handle this gracefully and keep the site up but just return an error message when the user tries to use the site search or other functionality that requires Search?

Sitecore seems to check connectivity to Solr pretty early on and bomb out if it can't connect to one or more indexes.

2 Answers 2

14

There is. Sitecore has open sourced a patch to fix this. The code is on github, you'll need to download it and build the patch against your version of Sitecore. You may need to adjust the code to work with different releases. For example, I had to install this on a 7.x instance and it required some code changes to build.

https://github.com/andrew-at-sitecore/Sitecore.Support.391039

Basically what this does is wrap all the Solr stuff in checks to a monitor class, and logs errors if Solr is unavailable rather than throwing exceptions. This will work on CD servers if your code handles empty search results gracefully. It will not help the Sitecore backend, that will still break if Solr is down.

I have a blog post about it here: http://www.chrissulham.com/keep-sitecore-online-when-solr-fails/

1
  • 1
    Chris thanks very much for this. I figured someone would have a solution for this somewhere. Thankfully we are on 8.1 update 2 so It should be good to go. I'll try and get this in place ASAP. I feel like this should be out of the box with a config switch really though. Hopefully it will make it into a later release of Sitecore. Commented Nov 30, 2016 at 14:33
2

We applied this support patch and to add to Chris Answer - as you master indexes shouldn't be available on your CD servers you will likely need to patch this in with two different config patch files on your CD and CA servers otherwise you will get an error:

CD:

    <?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>      
        <contentSearch>
      <!--search index connection failure patch (Sitecore.Support.391039)-->
      <configuration>
        <indexes>
           <index id="sitecore_analytics_index">
            <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
          </index>
          <index id="sitecore_core_index">
            <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
          </index>
          <index id="sitecore_web_index">
            <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
          </index>
          <index id="sitecore_marketing_asset_index_web">
            <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
          </index>
          <index id="sitecore_marketingdefinitions_web">
            <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
          </index>
          <index id="sitecore_fxm_web_index">
            <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
          </index>
          <index id="social_messages_web">
            <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
          </index>
        </indexes>
      </configuration>
        </contentSearch>
    </sitecore>
</configuration>

CA:

        <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
        <sitecore>      
            <contentSearch>
          <!--search index connection failure patch (Sitecore.Support.391039)-->
          <configuration>
            <indexes>
               <index id="sitecore_analytics_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_core_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_master_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_web_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_marketing_asset_index_master">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_marketing_asset_index_web">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_marketingdefinitions_master">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_marketingdefinitions_web">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_testing_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_suggested_test_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_fxm_master_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_fxm_web_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="sitecore_list_index">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="social_messages_master">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
              <index id="social_messages_web">
                <patch:attribute name="type">Sitecore.Support.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.Support.391039</patch:attribute>
              </index>
            </indexes>
          </configuration>
            </contentSearch>
        </sitecore>
    </configuration>

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.