4

From certain point in time I cannot start Sitecore XConnect Search Indexer Windows Service anymore. I can see just below exceptions in logs.

I am running Sitecore 9 Update 2.

This is how my C:\inetpub\wwwroot\sc9u2.xconnect\App_data\Diagnostics folder looks like:

enter image description here

I can see this exception in AppDomain log:

2018-07-27 15:16:23.986 +02:00 [Information] Starting Xdb Indexer App Domain, Machine: WIN-G4E0D3RI00V, InstanceName: XConnectIndexer_AppDomain

2018-07-27 15:16:26.773 +02:00 [Information] SystemPerformanceCounters Constructor, Instance:XConnectIndexer, Path: App_Data\Diagnostics, CounterFilePattern: *.json

2018-07-27 15:16:27.976 +02:00 [Error] Exception occurred during instantiating of IndexerHost.
System.InvalidOperationException: Unable to resolve service for type 'Sitecore.Xdb.Collection.Indexing.IIndexInitializer' while attempting to activate 'Sitecore.Xdb.Collection.Indexing.SingleThreadedIndexer'.
   at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.Configuration.ConfigurationServiceType.c__DisplayClass24_0.b__0(IServiceProvider sp)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Sitecore.XConnect.Search.Indexer.IndexerHost..ctor(IConfigurationRoot config)
   at Sitecore.XConnect.Search.Indexer.IndexerAppDomainHost.IndexerHostAppDomainBridge..ctor()

I can see this exception in it's AppHost log:

2018-07-27 15:16:22.027 +02:00 [Information] Xdb Indexer Application Start, Machine: WIN-G4E0D3RI00V, InstanceName: XConnectIndexer_AppHost

2018-07-27 15:16:28.068 +02:00 [Error] Failed to start the indexer host
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Unable to resolve service for type 'Sitecore.Xdb.Collection.Indexing.IIndexInitializer' while attempting to activate 'Sitecore.Xdb.Collection.Indexing.SingleThreadedIndexer'.
   at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.Configuration.ConfigurationServiceType.c__DisplayClass24_0.b__0(IServiceProvider sp)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Sitecore.XConnect.Search.Indexer.IndexerHost..ctor(IConfigurationRoot config)
   at Sitecore.XConnect.Search.Indexer.IndexerAppDomainHost.IndexerHostAppDomainBridge..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
   at Sitecore.XConnect.Search.Indexer.IndexerAppDomainHost.CreateAppDomainAndIndexer()
   at Sitecore.XConnect.Search.Indexer.IndexerAppDomainHost.Start()
   at Sitecore.XConnect.Search.Indexer.Service.OnStart(String[] args)

2018-07-27 15:16:28.083 +02:00 [Information] Xdb Indexer Application End, Machine: WIN-G4E0D3RI00V, InstanceName: XConnectIndexer_AppHost

Am I missing some files there?

Has anybody encountered this problem before?

  • can you verify the license and rights for the folder ? – Vlad Iobagiu Jul 27 '18 at 13:59
  • License and rights are correct. I have even tried to set permissions for Everyone as you suggested on Slack. Nothing helped – Peter Procházka Jul 27 '18 at 14:20
  • Check if the Sitecore.Xdb.Collection exists. That's where the SingleThreader is. – Marco Jul 27 '18 at 16:57
  • Btw, check to make sure that SOLR is working also. – Marco Jul 27 '18 at 16:59
  • Can you confirm that the files under app_data\jobs\continuous\IndexWorker are there? – Diego Jul 27 '18 at 18:02
3

If you have applied an update, there is a chance you have missed a file. If this is the case, I suggest to re apply the update files.

Context: the interface mentioned in the error message was introduced in one of the updates, so having new config files (with the updated DI registrations) without the assemblies would lead to that exact message.

  • This sounds like a probable cause even though I can't remember whether I have created that particular VM by upgrading existing Update 1 instance or creating instance from scratch with Update 2. I have too many VMs :) Need to write down some notes.txt file with description next time. Will take a look next week. Thanks for good hint for now. – Peter Procházka Jul 27 '18 at 20:12
  • 1
    Thanks @eglasius for the hint. I have just posted correct answer. I was missing some settings in one of config files – Peter Procházka Jul 31 '18 at 6:38
1

@eglasius answer lighted the bulb but didn't fix the problem.

I have remembered that I was setting indexing of anonymous contacts in C:\inetpub\wwwroot\sc9u2.xconnect\App_data\jobs\continuous\IndexWorker\App_data\Config\Sitecore\SearchIndexer\sc.XConnect.IndexerSettings.xml file based on this article: https://doc.sitecore.net/developers/xp/xconnect/xconnect-search-indexer/enable-anonymous-contact-indexing.html.

Seems that the article is not reflecting latest changes made in Update 2.

Instead of this (which is I believe only valid for Initial release and Update 1):

<Settings>
<Sitecore>
    <XConnect>
    <!-- SearchIndexer role requires Collection and CollectionSearch role services -->
    <SearchIndexer>
        <Services>
        <IndexerSettings>
            <Type>Sitecore.Xdb.Collection.Indexing.IndexerSettings, Sitecore.Xdb.Collection</Type>
            <LifeTime>Singleton</LifeTime>
            <Options>
            <IndexPIISensitiveData>false</IndexPIISensitiveData>
            <IndexAnonymousContactData>false</IndexAnonymousContactData>
            </Options>
        </IndexerSettings>
        <IIndexer>
            <Type>Sitecore.Xdb.Collection.Indexing.DecoratedIndexer, Sitecore.Xdb.Collection</Type>
            <As>Sitecore.Xdb.Collection.Indexing.IIndexer, Sitecore.Xdb.Collection</As>
            <LifeTime>Singleton</LifeTime>
        </IIndexer>
        <IIndexRebuildFlow>
            <Type>Sitecore.Xdb.Collection.Indexing.IndexRebuildFlow, Sitecore.Xdb.Collection</Type>
            <As>Sitecore.Xdb.Collection.Indexing.IIndexRebuildFlow, Sitecore.Xdb.Collection</As>
            <LifeTime>Singleton</LifeTime>
            <Options>
            <IncomingDataLagOnCompletion>0.00:00:05</IncomingDataLagOnCompletion>
            <!--Enable ParallelizationDegree setting to override default value which is (processorCount*4)-->
            <!--<ParallelizationDegree>16</ParallelizationDegree>-->
            <BatchSize>1000</BatchSize>
            </Options>
        </IIndexRebuildFlow>
        </Services>
    </SearchIndexer>
    </XConnect>
</Sitecore>
</Settings>

In Update 2 you need to use this setting instead:

<Settings>
  <Sitecore>
    <XConnect>
      <!-- SearchIndexer role requires Collection and CollectionSearch role services -->
      <SearchIndexer>
        <Services>
          <IndexerSettings>
            <Type>Sitecore.Xdb.Collection.Indexing.IndexerSettings, Sitecore.Xdb.Collection</Type>
            <LifeTime>Singleton</LifeTime>
            <Options>
                <!-- Indexer will split change set on chunks to improve memory consumption. Setting this option to 0, a negative value or removing the element completely, results in no splitting.-->
              <SplitRecordsThreshold>25000</SplitRecordsThreshold>
              <IndexPIISensitiveData>false</IndexPIISensitiveData>
              <IndexAnonymousContactData>true</IndexAnonymousContactData>
            </Options>
          </IndexerSettings>
          <IIndexer>
            <Type>Sitecore.Xdb.Collection.Indexing.DecoratedIndexer, Sitecore.Xdb.Collection</Type>
            <As>Sitecore.Xdb.Collection.Indexing.IIndexer, Sitecore.Xdb.Collection</As>
            <LifeTime>Singleton</LifeTime>
          </IIndexer>
          <IIndexerInitializer>
            <Type>Sitecore.Xdb.Collection.Indexing.DefaultIndexInitializer, Sitecore.Xdb.Collection</Type>
            <As>Sitecore.Xdb.Collection.Indexing.IIndexInitializer, Sitecore.Xdb.Collection</As>
            <LifeTime>Singleton</LifeTime>
          </IIndexerInitializer>
          <IIndexRebuildFlow>
            <Type>Sitecore.Xdb.Collection.Indexing.IndexRebuildFlow, Sitecore.Xdb.Collection</Type>
            <As>Sitecore.Xdb.Collection.Indexing.IIndexRebuildFlow, Sitecore.Xdb.Collection</As>
            <LifeTime>Singleton</LifeTime>
            <Options>
              <IncomingDataLagOnCompletion>0.00:00:05</IncomingDataLagOnCompletion>
              <!--Enable ParallelizationDegree setting to override default value which is (processorCount)-->
              <!--<ParallelizationDegree>16</ParallelizationDegree>-->
              <BatchSize>5000</BatchSize>
            </Options>
          </IIndexRebuildFlow>
          <IIndexRebuilderCountersDecorator>
              <Type>Sitecore.XConnect.Configuration.ServiceDecorator`2[[Sitecore.Xdb.Collection.Indexing.IIndexRebuilder, Sitecore.Xdb.Collection], [Sitecore.Xdb.Collection.Indexing.IndexRebuilderCountersDecorator, Sitecore.Xdb.Collection]], Sitecore.XConnect.Configuration</Type>
              <LifeTime>Singleton</LifeTime>
          </IIndexRebuilderCountersDecorator>
        </Services>
      </SearchIndexer>
    </XConnect>
  </Sitecore>
</Settings>

Mind the two new services definitions for IIndexerInitializer and IIndexRebuilderCountersDecorator which are only present in Update 2 version of that xml. Especially IIndexerInitializer was crutial for solving this problem.

I have also changed BatchSize to 5000 as also this setting / value has been changed.

After applying these settings and saving the xml file, I just starting the Sitecore XConnect Search Indexer Windows service for that instance and everything started to work once again. Without any restart or what so ever.

Lessons learnt - Always copy only settings that you need not the whole config file cause it might changed between versions! I was always doing this but for God knows which reason I have copied it all :(

I have run WinMerge and compared my two instances (one running properly and this one) and only change was in this file...

Hopefully this will help somebody to quickly diagnose similar exception.

  • You might also want to move the setting change to a separate file. See sitecore.stackexchange.com/a/8455 – eglasius Jul 31 '18 at 15:46
  • I am always patching @eglasius but I was in hurry and just wanted to try out something whether it will solve the problem with anonymous contacts. – Peter Procházka Aug 1 '18 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.