Lucene Indexes in Sitecore getting corrupted (ArgumentOutOfRangeException)

白昼怎懂夜的黑 提交于 2019-12-07 13:26:11

问题


We are having an issue with searching a Lucene Index in Sitecore. Everything works fine for a while, and then, after what appears to be a random amount of time, we start getting the following error on every single search against the index:

System.ArgumentOutOfRangeException 
Message: Non-negative number required. 
Parameter name: capacity Source: mscorlib 
  at System.Collections.Hashtable..ctor(Int32 capacity, Single loadFactor)
  at System.Collections.Hashtable.Clone() 
  at SupportClass.WeakHashTable.Clean() 
  at SupportClass.WeakHashTable.CleanIfNeeded() 
  at SupportClass.WeakHashTable.Add(Object key, Object value) 
  at Lucene.Net.Util.CloseableThreadLocal.Set(Object object) 
  at Lucene.Net.Index.TermInfosReader.GetThreadResources() 
  at Lucene.Net.Index.TermInfosReader.Get(Term term, Boolean useCache) 
  at Lucene.Net.Index.SegmentReader.DocFreq(Term t) 
  at Lucene.Net.Index.DirectoryReader.DocFreq(Term t) 
  at Lucene.Net.Search.Similarity.IdfExplain(Term term, Searcher searcher)
  at Lucene.Net.Search.TermQuery.CreateWeight(Searcher searcher) 
  at Lucene.Net.Search.BooleanQuery.BooleanWeight..ctor(BooleanQuery enclosingInstance, Searcher searcher) 
  at Lucene.Net.Search.BooleanQuery.CreateWeight(Searcher searcher) 
  at Lucene.Net.Search.Query.Weight(Searcher searcher) 
  at Lucene.Net.Search.Hits..ctor(Searcher s, Query q, Filter f, Sort o) 
  at Lucene.Net.Search.Searcher.Search(Query query, Sort sort) 
  at scSearchContrib.Searcher.QueryRunner.RunQuery(Query query, Boolean showAllVersions, String sortField, Boolean reverse, Int32 start, Int32 end) 
  at scSearchContrib.Searcher.QueryRunner.GetItems(IEnumerable`1 parameters, Boolean showAllVersions, String sortField, Boolean reverse, Int32 start, Int32 end) at

Looking at the .Net code and Lucene.Net code being called (via ILSpy), I can't see how this would actually happen. Calling .Clone() on a hashtable shouldn't allow a negative number for the hashtable capacity to be passed in.

This has happened several times, on multiple servers in our farm, and restarting IIS resolves the issue. This leads me to believe that there is some sort of in-memory corruption happening, but I'm not sure what would cause this or how to figure out what is going on.


回答1:


Sitecore support has a workaround for this for Sitecore 6.6. There are apparently some nasty thread-safety issues with the WeakHashTable class used in Lucene.NET 2.9.4. This issue is addressed in later versions of Lucene.NET and via the corresponding upgrades in Sitecore 7.




回答2:


Try increasing number of worker threads for Sitecore by adding following setting to web.config

<setting name="MaxWorkerThreads" value="100"/> 


来源:https://stackoverflow.com/questions/15906869/lucene-indexes-in-sitecore-getting-corrupted-argumentoutofrangeexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!