I’m sure my renderings were there yesterday?

As time goes on, something I’ve noticed is that as Sitecore evolves it is taking a greater reliance on search integration – making things like Solr ever more important. And that leads to an exciting new set of issues you come across if, for some reason, your search service is not available.

I wasted some perfectly good development time recently when some of my renderings vanished from published pages, thanks to this.


Updated to add: In the comments below, Sandip points out that Sitecore have a patch for this issue. You can resolve it in v9 Update 1 with Sitecore’s patch, and the fix is rolled into update 2.


My initial confusion

I was working on a “gated content” feature for a client’s site. I’d been doing some back-end work on a rendering for this, where editors were able to select an Experience Form for data capture, and the download that website user’s would receive for completing it. I’d got all the back-end code for this working happily the a day or two before, and was planning on spending another hour or so on some refactoring before merging the code. But when I fired up my dev site to get to work on this, my gated content component had vanished:

Confused, I checked presentation details. I checked I was still looking at the right source branch. I checked the “web” database, to make sure I’d published everything. And, I began to worry that my success from the night before had been some sort of very real-feeling dream.

Searching for an answer

I kept digging, to try and work out what was happening, and came across this in the site logs:

13184 07:14:12 WARN  '{183620B4-31CB-4FB5-9DB5-9D67414E7104}' is not valid datasource for web or user does not have permissions to access.
13184 07:14:12 WARN  Failed to execute datasource query System.NullReferenceException: Object reference not set to an instance of an object.
   at Sitecore.ContentSearch.SitecoreItemCrawler.IsExcludedFromIndex(SitecoreIndexableItem indexable, Boolean checkLocation)
   at Sitecore.ContentSearch.SitecoreItemCrawler.GetContextIndexRanking(IIndexable indexable)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.Min(IEnumerable`1 source)
   at Sitecore.ContentSearch.AbstractSearchIndex.Sitecore.ContentSearch.Pipelines.GetContextIndex.IContextIndexRankable.GetContextIndexRanking(IIndexable indexable)
   at Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex.<>c__DisplayClass6_0.<RankContextIndexes>b__0(ISearchIndex i)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex.GetContextIndex(IIndexable indexable, GetContextIndexArgs args)
   at Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex.Process(GetContextIndexArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Abstractions.CorePipelineWrapper.Run(String pipelineName, PipelineArgs args)
   at Sitecore.ContentSearch.Pipelines.GetContextIndex.GetContextIndexPipeline.Run(ICorePipeline pipeline, GetContextIndexArgs args)
   at Sitecore.Mvc.ExperienceEditor.DatasourceValidator.DatasourceValidator.IsDatasourceValid(String dataSource, Database database)

My first thought on reading that top line was that I’d done something odd to my datasource item by mistake. So I re-checked that this existed, that my compoinent pointed to it correctly, that it had the right template for my rendering, and that it didn’t have any unexpected security applied. But all of those were correct.

Which lead me to looking at the second part of the error – the NullReferenceException.

Skimming the log, I’d seen “null reference” and assumed that my code was throwing because the datasource item wasn’t accessible. But when I read that log entry a second time I realised that actually my code was not mentioned in that stack trace. It’s all Sitecore code, and it’s talking about the ContentSearch APIs and “datasource queries”.

Now I knew there was no query in the datasource set on my component, as it just used the ID of the target item. But this started me thinking about search indexes – which were provided by Solr in this case. So I tried browsing to the Solr UI to check that it was happy, and bingo:

No Solr. I had it installed as an NSSM service, so checking the Services admin tool in Windows:

I restarted that service, and refreshed my page – no difference. But after an iisreset:

Bingo! My work was back.

At this point I remembered I’d stopped a load of “non-essential” services the night before to make my laptop battery last for a long train journey…

*epic facepalm*

Conclusions

More and more bits of Sitecore are relying on Solr these days. The xConnect services need it. The Experience Forms editing UI needs it. And it seems there is also a datasource validation pipeline component which also relies on it.

So you need to make sure it’s up and running if you don’t want to feel as silly as I did…

Advertisements

4 thoughts on “I’m sure my renderings were there yesterday?

  1. Great post! I’ve had this issue a few times too, and it’s really an annoying behavior of Sitecore. What I’ve experienced is that a node in a Solr Cloud Cluster was offline for a short period of time, and IIS did a restart of the worker process. From that point, Sitecore won’t recover until someone recycles the worker process again. Bad design in my opinion.

    • Yes, definitely an problem that needs some attention. I wasn’t aware it was also an issue with individual Solr nodes failing. I’d best watch out for that in production… Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.