Sometimes when we change config file or deploy new code, we see this exception on first load of page:
Server Error in '/' Application.
Index sitecore_marketingdefinitions_master was not found
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Sitecore.ContentSearch.Exceptions.IndexNotFoundException: Index sitecore_marketingdefinitions_master was not found
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[IndexNotFoundException: Index sitecore_marketingdefinitions_master was not found] Sitecore.ContentSearch.ContentSearchManager.GetIndex(String name) +127 Sitecore.Marketing.Search.BaseDefinitionSearchProvider
2..ctor(String indexName) +91 Sitecore.Marketing.Search.ProfileDefinitionSearchProvider..ctor(IDefinitionManagerSearchSettings searchSettings) +113 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider) +339 Microsoft.Extensions.DependencyInjection.ScopedCallSite.Invoke(ServiceProvider provider) +116 Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider) +111 Microsoft.Extensions.DependencyInjection.ScopedCallSite.Invoke(ServiceProvider provider) +116 Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService(IServiceProvider provider) +69 Sitecore.Marketing.Definitions.DefinitionManagerFactory.GetDefinitionManager() +84 Sitecore.Analytics.Data.<>c__DisplayClass7_0.<.ctor>b__4() +69 System.Lazy
1.CreateValue() +737 System.Lazy1.LazyInitValue() +431 Sitecore.Analytics.Data.MarketingDefinitions.InitializeProfilesWithDefaultValues() +80 System.Lazy
1.CreateValue() +737 System.Lazy`1.LazyInitValue() +431 Sitecore.Analytics.Data.TrackingField.InitializeProfiles() +106 Sitecore.Analytics.Data.TrackingField..ctor(Field innerField) +133 Sitecore.Analytics.Data.TrackingField.GetTrackingField(Item item) +106 Sitecore.Analytics.Data.ProfileUtil.GetProfiles(Item item, TrackingField& trackingField) +41 Sitecore.Shell.Applications.ContentEditor.Pipelines.RenderContentEditorHeader.ProfileCardsControl.RenderProfileCardIcons(Item item, HtmlTextWriter output, Boolean& hasCardsConfigured) +128 Sitecore.Shell.Applications.ContentEditor.Pipelines.RenderContentEditorHeader.ProfileCardsControl.RenderProfileCards(Item item, HtmlTextWriter output) +570 Sitecore.Shell.Applications.ContentEditor.Pipelines.RenderContentEditorHeader.ProfileCardsControl.OnInit(EventArgs e) +260 System.Web.UI.Control.InitRecursive(Control namingContainer) +460 System.Web.UI.Control.InitRecursive(Control namingContainer) +225 System.Web.UI.Control.AddedControl(Control control, Int32 index) +245 Sitecore.Web.UI.Sheer.ClientPage.AddControl(Control parent, Control control, String placeholder) +234 Sitecore.Shell.Applications.ContentManager.Editor.Render(RenderContentEditorArgs args, Control parent) +283 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.RenderEditor(Item item, Item root, Control editorsContainer, Boolean showEditor) +291 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.UpdateEditor(Item folder, Item root, Boolean showEditor) +487 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update() +568 Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(EventArgs e) +212[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +128 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146 Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj) +89 Sitecore.Shell.Applications.ContentManager.ContentEditorPage.OnPreRender(EventArgs e) +143 System.Web.UI.Control.PreRenderRecursiveInternal() +200 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7574
When we refresh the page, everything is working as expected.
Has anybody encountered similar issues?
How we can prevent this happening?