Sitecore 8.1 : Lucene.Net.Store.LockObtainFailedEx

2019-09-08 05:05发布

问题:

We have sitecore 8.1 hosted in Azure WEB Apps. The setup is 1xCA and 2xCD and using LUCENE

We noticed a error log below which I googled but could not get solution.

ManagedPoolThread #12 2015:12:28 23:22:33 ERROR Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
   at Sitecore.Reflection.MethodInstance.Invoke()
   at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.PipelineMethod.Invoke(Object[] parameters)
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Jobs.Job.ThreadEntry(Object state)

Nested Exception

Exception: Lucene.Net.Store.LockObtainFailedException
Message: Lock obtain timed out: NativeFSLock@D:\home\site\wwwroot\App_Data\data\indexes\sitecore_web_index\write.lock: System.IO.IOException: The process cannot access the file 'D:\home\site\wwwroot\App_Data\data\indexes\sitecore_web_index\write.lock' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at Lucene.Net.Store.NativeFSLock.Obtain()
Source: Lucene.Net
   at Lucene.Net.Store.Lock.Obtain(Int64 lockWaitTimeout)
   at Sitecore.ContentSearch.LuceneProvider.DiagnosticLockFactory.DiagnosticLock.Obtain(Int64 lockWaitTimeout)
   at Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean create, IndexDeletionPolicy deletionPolicy, Int32 maxFieldLength, IndexingChain indexingChain, IndexCommit commit)
   at Lucene.Net.Index.IndexWriter..ctor(Directory d, Analyzer a, Boolean create, MaxFieldLength mfl)
   at Sitecore.ContentSearch.LuceneProvider.Sharding.LuceneShard.CreateWriter(Directory directory, LuceneIndexMode mode)
   at Sitecore.ContentSearch.LuceneProvider.Sharding.LuceneShard.CreateWriter(IProviderUpdateContext context, LuceneIndexMode mode)
   at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.CreateWriter(IProviderUpdateContext context, Shard shard, LuceneIndexMode mode)
   at Sitecore.ContentSearch.LuceneProvider.LuceneUpdateContext.InitializeWriter(UpdateContextShardState shardState, LuceneIndexMode mode)
   at Sitecore.ContentSearch.LuceneProvider.LuceneUpdateContext.InitializeWriters()
   at Sitecore.ContentSearch.LuceneProvider.LuceneUpdateContext.EnsureInitializeWriters()
   at Sitecore.ContentSearch.LuceneProvider.LuceneUpdateContext.UpdateDocument(Object itemToUpdate, Object criteriaForUpdate, IExecutionContext[] executionContexts)
   at Sitecore.ContentSearch.LuceneProvider.LuceneUpdateContext.UpdateDocument(Object itemToUpdate, Object criteriaForUpdate, IExecutionContext executionContext)
   at Sitecore.ContentSearch.LuceneProvider.LuceneIndexOperations.Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
   at Sitecore.ContentSearch.SitecoreItemCrawler.UpdateItemVersion(IProviderUpdateContext context, Item version, IndexEntryOperationContext operationContext)
   at Sitecore.ContentSearch.SitecoreItemCrawler.DoUpdate(IProviderUpdateContext context, SitecoreIndexableItem indexable, IndexEntryOperationContext operationContext)
   at Sitecore.ContentSearch.SitecoreItemCrawler.Update(IProviderUpdateContext context, IIndexableUniqueId indexableUniqueId, IndexEntryOperationContext operationContext, IndexingOptions indexingOptions)
   at Sitecore.ContentSearch.AbstractSearchIndex.PerformUpdate(IEnumerable`1 indexableInfo, IndexingOptions indexingOptions)
   at Sitecore.ContentSearch.AbstractSearchIndex.Update(IEnumerable`1 indexableInfo)

Nested Exception

Exception: System.IO.IOException
Message: The process cannot access the file 'D:\home\site\wwwroot\App_Data\data\indexes\sitecore_web_index\write.lock' because it is being used by another process.
Source: mscorlib
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at Lucene.Net.Store.NativeFSLock.Obtain()

Web Apps makes a bit tricky to debug as we don't have access to IIS or event logs etc. Any suggestion would be appreciated.

回答1:

What you should do is go to that location and just remove the write.lock file. If its being used by another process then use something like fileunlocker, unlock the file and then delete. It does this quite a lot with git and lucene.



回答2:

In Azure Web Apps, you do have access to those logs and many other troubleshooting tools. Navigate to //<yourwebsitename>.scm.azurewebsites.net and explore your options in the Kudu tool. Especially check the Tools | Support menu option. You'll need to enable logging in your web app first.