Lucene MergeException When Using SOLR

Posted 05/12/2017 by Ed Kapuscinski

Today I finally beat a thing that's been causing me a headache for a while: a Lucene.net error that would cause my app pool to recycle, and Visual Studio to pause the process and want to debug it. This, of course, made doing anything in the CMS a major pain.

My Lucene Error

I did my usual thing of Googling the issue, which usually provides a solution, but in this case, I wasn't finding exactly what I needed. This was because, in my environment, we were using SOLR instead of just straight Lucene.

When I looked in the logs, I saw the following.

  
Lucene.Net.Index.MergePolicy.MergeException was unhandled
Message: An unhandled exception of type 'Lucene.Net.Index.MergePolicy.MergeException' occurred in Lucene.Net.dll

Lucene Merge Thread #0 10:52:15 ERROR Unhandled exception detected. The ASP.NET worker process will be terminated. 
Exception: Lucene.Net.Index.MergePolicy+MergeException
Message: Exception of type 'Lucene.Net.Index.MergePolicy+MergeException' was thrown.
Source: Lucene.Net
   at Lucene.Net.Index.ConcurrentMergeScheduler.HandleMergeException(Exception exc) in d:\Lucene.Net\FullRepo\trunk\src\core\Index\ConcurrentMergeScheduler.cs:line 430
   at Lucene.Net.Index.ConcurrentMergeScheduler.MergeThread.Run() in d:\Lucene.Net\FullRepo\trunk\src\core\Index\ConcurrentMergeScheduler.cs:line 394
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Nested Exception

Exception: System.IndexOutOfRangeException
Message: Index was outside the bounds of the array.
Source: Lucene.Net
   at Lucene.Net.Index.IndexWriter.HandleMergeException(Exception t, OneMerge merge) in d:\Lucene.Net\FullRepo\trunk\src\core\Index\IndexWriter.cs:line 4641
   at Lucene.Net.Index.IndexWriter.Merge(OneMerge merge) in d:\Lucene.Net\FullRepo\trunk\src\core\Index\IndexWriter.cs:line 4674
   at Lucene.Net.Index.ConcurrentMergeScheduler.MergeThread.Run() in d:\Lucene.Net\FullRepo\trunk\src\core\Index\ConcurrentMergeScheduler.cs:line 370

My Googling of the issue turned up suggestions that the index was corrupted, and that the fix was to clean out the indexes and rebuild them. Great! I headed into the SOLR indexes and cleaned them all out. Restart the service and...

... the problem persisted.

Turns out that, even with SOLR in place, there's still a Lucene index being used: "__system". This index lived in the site's data folder's indexes folder. I went in there, cleaned out the index files in there, and my error went away. So, if you're having issues with Lucene, and you're wondering why since you're using SOLR, make sure you know about this one remaining Lucene index that you need to take care of.

Share:

Archive

Syndication