Copied to clipboard

Flag this post as spam?

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


  • Chris Roberts 74 posts 106 karma points c-trib
    Jan 08, 2017 @ 13:14
    Chris Roberts
    0

    Lucene Exception when Deleting Content Using Content Service

    Hi,

    I am using Umbraco v7.5.3.

    We have a situation where (due to some bad decisions made when importing some data) we have a site that has lots of duplicate content which needs to be deleted.

    I have written some code which identifies the content to be deleted and then sits in a loop attempting to delete them using the Content Service.

    However, when running the code I repeatedly get a Lucene exception - "this IndexWriter is closed".

    Can anyone suggest what the problem might be and how I should go about fixing it, please?!

    A fragment of the code I am using, and the stack trace are below...

    // Delete the articles whose names end with ")"
    foreach (IPublishedContent ArticleToDelete in MatchingNews.Where(x => x.Name.EndsWith(")")))
    {
        IContent ContentToDelete = ContentSvc.GetById(ArticleToDelete.Id);
        ContentSvc.Delete(ContentToDelete);
    }
    
    [AlreadyClosedException: this IndexWriter is closed]
       Lucene.Net.Index.IndexWriter.EnsureOpen(Boolean includePendingClose) +140
       Lucene.Net.Index.IndexWriter.GetDirectory() +12
       Examine.LuceneEngine.Providers.LuceneSearcher.GetLuceneDirectory() in X:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\LuceneSearcher.cs:254
       Examine.LuceneEngine.Providers.LuceneSearcher.ValidateSearcher(Boolean forceReopen) in X:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\LuceneSearcher.cs:277
       Examine.LuceneEngine.Providers.LuceneSearcher.GetSearchFields() in X:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\LuceneSearcher.cs:238
       Examine.LuceneEngine.Providers.BaseLuceneSearcher.CreateSearchCriteria(String type, BooleanOperation defaultOperation) in X:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\BaseLuceneSearcher.cs:117
       Examine.LuceneEngine.Providers.BaseLuceneSearcher.CreateSearchCriteria() in X:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\BaseLuceneSearcher.cs:212
       UmbracoExamine.UmbracoContentIndexer.DeleteFromIndex(String nodeId) +118
       Examine.ExamineManager._DeleteFromIndex(String nodeId, IEnumerable`1 providers) in X:\Projects\Examine\Examine\Projects\Examine\ExamineManager.cs:213
       Umbraco.Web.Search.ExamineEvents.DeleteIndexForEntity(Int32 entityId, Boolean keepIfUnpublished) +251
       Umbraco.Web.Search.ExamineEvents.PublishedPageCacheRefresherCacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e) +281
       Umbraco.Core.Events.TypedEventHandler`2.Invoke(TSender sender, TEventArgs e) +0
       Umbraco.Core.Cache.CacheRefresherBase`1.OnCacheUpdated(TInstanceType sender, CacheRefresherEventArgs args) +49
       Umbraco.Core.Cache.TypedCacheRefresherBase`2.Remove(TEntityType instance) +86
       Umbraco.Web.Cache.PageCacheRefresher.Remove(IContent instance) +144
       Umbraco.Core.Sync.ServerMessengerBase.DeliverLocal(ICacheRefresher refresher, MessageType messageType, Func`2 getId, IEnumerable`1 instances) +577
       Umbraco.Core.Sync.ServerMessengerBase.Deliver(IEnumerable`1 servers, ICacheRefresher refresher, MessageType messageType, Func`2 getId, IEnumerable`1 instances) +134
       Umbraco.Core.Sync.ServerMessengerBase.PerformRemove(IEnumerable`1 servers, ICacheRefresher refresher, Func`2 getNumericId, T[] instances) +222
       Umbraco.Web.Cache.DistributedCache.Remove(Guid factoryGuid, Func`2 getNumericId, T[] instances) +192
       Umbraco.Web.Cache.DistributedCacheExtensions.RemovePageCache(DistributedCache dc, IContent[] content) +236
       Umbraco.Web.Cache.CacheRefresherEventHandler.UnPublishSingle(IContent content) +47
       Umbraco.Web.Cache.CacheRefresherEventHandler.PublishingStrategy_UnPublished(IPublishingStrategy sender, PublishEventArgs`1 e) +188
       Umbraco.Core.Events.TypedEventHandler`2.Invoke(TSender sender, TEventArgs e) +0
       Umbraco.Core.Events.EventExtensions.RaiseEvent(TypedEventHandler`2 eventHandler, TArgs args, TSender sender) +16
       Umbraco.Core.Publishing.PublishingStrategy.UnPublishingFinalized(IContent content) +121
       Umbraco.Core.Services.ContentService.UnPublishDo(IContent content, Boolean omitCacheRefresh, Int32 userId) +852
       Umbraco.Core.Services.ContentService.Umbraco.Core.Services.IContentServiceOperations.UnPublish(IContent content, Int32 userId) +15
       Umbraco.Core.Services.ContentService.Umbraco.Core.Services.IContentServiceOperations.Delete(IContent content, Int32 userId) +319
       Umbraco.Core.Services.ContentService.Delete(IContent content, Int32 userId) +26
       xxxxWebsite.Controllers.DataController.DeleteDuplicateNews() in C:\Projects\Clients\xxxx Website\xxxxWebsite\Controllers\DataController.cs:149
       lambda_method(Closure , ControllerBase , Object[] ) +61
       System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
       System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
       System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +34
       System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
       System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
       System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
       System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
       System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
       System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
       System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
       System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
       System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +38
       System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +28
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
       System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765121
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
    
  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Jan 09, 2017 @ 10:33
    Damiaan
    0

    Do you have a node with a bracket in its name? If so, try to save & publish.

    If you can reproduce this on an brand new umbraco, than it's a bug. In that case I would post this to http://issues.umbraco.org.

  • Chris Roberts 74 posts 106 karma points c-trib
    Jan 10, 2017 @ 14:48
    Chris Roberts
    0

    Hi Damiaan,

    Thanks - yes - all of the nodes had a ) in them as I was looking to remove duplicates which were named like this...

    • Example Document
    • Example Document (1)
    • Example Document (2)
    • Example Document (3)

    I also tried changing the container to use a list view in Umbraco, then selected multiple documents in the UI and clicked 'Delete', which resulted in the same exception.

    If I get the chance I'll try it on a clean install and file a bug... it does feel more like a bug as it was also happening using the Umbraco UI, not just my code.

    Thanks, Chris

  • Chris Zielin 19 posts 156 karma points
    Nov 28, 2017 @ 22:33
    Chris Zielin
    0

    Chris,

    Did you ever find a solution to this? If so, would you mind sharing? I'm running into a similar issue. I have thousands of nodes that I'm unable to delete either through the UI or via the content service.

    Thanks, Chris

Please Sign in or register to post replies

Write your reply to:

Draft