Deadlock on application start


Description

Using federated authentication with Federated Experience Manager (FXM) might prevent Sitecore XP instances from starting.

If a Sitecore XP application is not starting, then create a memory dump of the process. If there is a deadlock between threads calling FxmSiteProvider.FxmSites and DefaultSiteContextFactory.GetSites() methods, then apply the solution that follows in this article.

Solution

To resolve the issue, create a configuration patch file in the \App_Config\Include\zzz folder of the solution:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore role:require="Standalone or ContentDelivery or ContentManagement">
    <hooks>
      <hook type="Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.ValidateIdentity.CheckIdentityProvider, Sitecore.Owin.Authentication" resolve="true" patch:before = "*[1]" />
    </hooks>
  </sitecore>
</configuration>

The configuration patch file should be added to all Content Management and Content Delivery instances. The patch is also applicable if Sitecore XP is run as a Standalone role.
After applying the provided configuration file, an exception appears in the logs during the application startup. This exception is handled, and it only appears once through the application lifetime. It does not have any negative impact on functionality or performance, and therefore it can be safely ignored.

Note

The Deadlock causes site unresponsiveness on application start issue might lead to similar symptoms.