Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Jacobsen 293 posts 1281 karma points
    Jul 25, 2019 @ 09:50
    Bo Jacobsen
    0

    Lock obtain timed out: SimpleFSLock@

    Hi all.

    Using Umbraco 8.1.0

    I have created my own index, but often i get a write lock on it and i dunno why. In this error i am trying to delete some content wich content type alias aint included in the CustomContentIndex

    <Error>
      <Message>Something went wrong</Message>
      <ExceptionMessage>Exceptions were thrown by listed actions.</ExceptionMessage>
      <ExceptionType>System.AggregateException</ExceptionType>
      <StackTrace>
     at Umbraco.Core.Scoping.ScopeContext.ScopeExit(Boolean completed) at Umbraco.Core.Scoping.Scope.<>c__DisplayClass72_0.<RobustExit>b__2() at 
       Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) at Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) 
       at Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) at Umbraco.Core.Scoping.Scope.RobustExit(Boolean completed, Boolean onException) 
       at Umbraco.Core.Scoping.Scope.DisposeLastScope() at Umbraco.Core.Scoping.Scope.Dispose() at Umbraco.Core.Services.Implement.ContentService.Delete(IContent content, Int32 userId) 
       at MyServices.MyApiService.HandleData(ApiData data, Int32 activitiesPageId) in D:\...\MyServices\MyApiService.cs:line 241 at MyProject.MyApiController.GetFullUpDate(String request)
       in D:\...\ApiController.cs:line 60
      </StackTrace>
      <InnerException>
        <Message>An error has occurred.</Message>
        <ExceptionMessage>
         Lock obtain timed out: SimpleFSLock@D:\...\MyProject\App_Data\TEMP\ExamineIndexes\CustomContentIndex\write.lock
        </ExceptionMessage>
        <ExceptionType>Lucene.Net.Store.LockObtainFailedException</ExceptionType>
        <StackTrace>
         at Lucene.Net.Store.Lock.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) ved Examine.LuceneEngine.Providers.LuceneIndex.WriterFactory(Directory d) 
         at Examine.LuceneEngine.WriterTracker.<>c__DisplayClass7_0.<GetWriter>b__0(String s) at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) 
         at Examine.LuceneEngine.WriterTracker.GetWriter(Directory dir, Func`2 factory) ved Examine.LuceneEngine.Providers.LuceneIndex.CreateIndexWriter() 
         at Examine.LuceneEngine.Providers.LuceneIndex.GetIndexWriter() at Examine.LuceneEngine.Providers.LuceneIndex.CreateSearcher() at System.Lazy`1.CreateValue() 
         at System.Lazy`1.LazyInitValue() ved System.Lazy`1.get_Value() at Examine.LuceneEngine.Providers.LuceneIndex.GetSearcher() at Umbraco.Examine.UmbracoContentIndex.PerformDeleteFromIndex(IEnumerable`1 itemIds, Action`1 onComplete) 
         at Examine.Providers.BaseIndexProvider.DeleteFromIndex(IEnumerable`1 itemIds) 
         at Umbraco.Web.Search.ExamineComponent.DeferedDeleteIndex.Execute(ExamineComponent examineComponent, Int32 id, Boolean keepIfUnpublished) at Umbraco.Web.Search.ExamineComponent.DeferedDeleteIndex.Execute() 
         at Umbraco.Web.Search.ExamineComponent.DeferedActions.Execute() at Umbraco.Web.Search.ExamineComponent.DeferedActions.<>c.<Get>b__1_1(Boolean completed, DeferedActions actions) 
         at Umbraco.Core.Scoping.ScopeContext.EnlistedObject`1.Execute(Boolean completed) at Umbraco.Core.Scoping.ScopeContext.ScopeExit(Boolean completed)
        </StackTrace>
      </InnerException>
    </Error>
    

    Here is my CustomContentIndex where i only include content type textPage and making a combinedField in culture if it varies.

    public class CustomIndexCreator : LuceneIndexCreator, IUmbracoIndexesCreator
    {
        private readonly IProfilingLogger _profilingLogger;
        private readonly ILocalizationService _localizationService;
        private readonly IPublicAccessService _publicAccessService;
    
        public CustomIndexCreator(IProfilingLogger profilingLogger,
        ILocalizationService localizationService,
        IPublicAccessService publicAccessService)
        {
            _profilingLogger = profilingLogger;
            _localizationService = localizationService;
            _publicAccessService = publicAccessService;
        }
    
        public override IEnumerable<IIndex> Create()
        {
            var indexContent = new UmbracoContentIndex("CustomContentIndex",
                CreateFileSystemLuceneDirectory("CustomContentIndex"),
                new UmbracoFieldDefinitionCollection(),
                new StandardAnalyzer(Version.LUCENE_30),
                _profilingLogger,
                _localizationService,
                new ContentValueSetValidator(true, false, _publicAccessService, includeItemTypes: new string[] { "textPage" }));
    
            return new[] { indexContent };
        }
    }
    
    public class IndexCreatorComponent : IComponent
    {
        private readonly IExamineManager _examineManager;
        private readonly ILocalizationService _localizationService;
        private readonly CustomIndexCreator _customIndexCreator;
        private readonly ILogger _logger;
    
        public IndexCreatorComponent(IExamineManager examineManager, ILocalizationService localizationService, CustomIndexCreator customIndexCreator, ILogger logger)
        {
            _examineManager = examineManager;
            _localizationService = localizationService;
            _customIndexCreator = customIndexCreator;
            _logger = logger;
        }
    
        public void Initialize()
        {
            foreach (var index in _customIndexCreator.Create())
            {
                _examineManager.AddIndex(index);
            }
    
            if (_examineManager.TryGetIndex("CustomContentIndex", out IIndex customContentIndex))
            {
                if (customContentIndex is BaseIndexProvider indexProviderContent)
                {
                    indexProviderContent.TransformingIndexValues += IndexProviderTransformingIndexValues;
                }
            }
        }
    
        private void IndexProviderTransformingIndexValues(object sender, IndexingItemEventArgs e)
        {
            if (e.ValueSet.Category == IndexTypes.Content)
            {
                CreateContentCombinedField(e);
    
                var variesByCulture = e.ValueSet.Values.FirstOrDefault(x => x.Key == UmbracoContentIndex.VariesByCultureFieldName);
                if (variesByCulture.Value != null && variesByCulture.Value[0].Equals("y"))
                {
                    var availableCultures = _localizationService.GetAllLanguages();
                    foreach (var availableCulture in availableCultures)
                    {
                        var culture = availableCulture.CultureInfo.ToString().ToLower();
                        CreateContentCombinedField(e, culture);
                    }
                }
            }
        }
    
        public void CreateContentCombinedField(IndexingItemEventArgs e, string culture = null)
        {
            var stringBuilder = new StringBuilder();
    
            var fieldKeys = new string[] { "nodeName", "title", "grid", "text" };
    
            var fieldName = "combinedField";
            if (!string.IsNullOrEmpty(culture))
            {
                fieldName = $"{fieldName}_{culture}";
                for (var i = 0; i < fieldKeys.Length; i++)
                {
                    fieldKeys[i] = $"{fieldKeys[i]}_{culture}";
                }
            }
    
            var fields = e.ValueSet.Values.Where(x => fieldKeys.Contains(x.Key));
            foreach (var fieldValues in fields)
            {
                foreach (var value in fieldValues.Value)
                {
                    if (value != null)
                    {
                        stringBuilder.AppendLine(value.ToString());
                    }
                }
            }
    
            e.ValueSet.TryAdd(fieldName, stringBuilder.ToString());
            stringBuilder.Clear();
        }
    
        public void Terminate() { }
    }
    
  • Timo Keller 9 posts 109 karma points
    Jul 30, 2019 @ 11:34
    Timo Keller
    0

    Hi Bo,

    did you resolve this problem, because i get the same errors using my own index.

    Greets Timo

  • Bo Jacobsen 293 posts 1281 karma points
    Aug 05, 2019 @ 14:37
    Bo Jacobsen
    0

    Hi Timo.

    I did not resolve it 100%, but i did get it to occur less by updating Examine from 1.0.0 to 1.0.1.

Please Sign in or register to post replies

Write your reply to:

Draft