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 590 posts 2366 karma points
    Dec 20, 2021 @ 09:41
    Bo Jacobsen
    0

    Error indexing queue items - Collection was modified; enumeration operation may not execute.

    Hi all.

    Using Umbraco 8.16.0, Lucene.Net 3.0.3 and Examine 1.2.2.

    First off. Everytime we recycled the app pool, the indexes went empty. Then we used <add key="Umbraco.Core.MainDom.Lock" value="SqlMainDomLock" /> in the Web.config <appSettings> and that seems to fix that issue.

    The issue we got at hand, is that from time to time we get an Error indexing queue items with Collection was modified; enumeration operation may not execute. This lead to Cannot index queue items, the index is currently locked and then emptied.

    System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at CustomCode.Components.IndexCreatorComponent.CreateContentCombinedField(IDictionary`2 valueSetValues, String culture) in D:\CustomCode\Components\IndexCreatorComponent.cs:line 944
       at CustomCode.Components.IndexCreatorComponent.IndexProviderTransformingIndexValues(Object sender, IndexingItemEventArgs e) in D:\CustomCode\Components\IndexCreatorComponent.cs:line 840
       at Examine.Providers.BaseIndexProvider.OnTransformingIndexValues(IndexingItemEventArgs e) in D:\a\1\s\src\Examine\Providers\BaseIndexProvider.cs:line 146
       at Umbraco.Examine.UmbracoExamineIndex.OnTransformingIndexValues(IndexingItemEventArgs e) in D:\a\1\s\src\Umbraco.Examine\UmbracoExamineIndex.cs:line 177
       at Examine.LuceneEngine.Providers.LuceneIndex.ProcessIndexQueueItem(IndexOperation op, IndexWriter writer) in D:\a\1\s\src\Examine\LuceneEngine\Providers\LuceneIndex.cs:line 1331
       at Examine.LuceneEngine.Providers.LuceneIndex.ProcessQueueItem(IndexOperation item, IndexWriter writer) in D:\a\1\s\src\Examine\LuceneEngine\Providers\LuceneIndex.cs:line 1133
       at Examine.LuceneEngine.Providers.LuceneIndex.ForceProcessQueueItems(Boolean block) in D:\a\1\s\src\Examine\LuceneEngine\Providers\LuceneIndex.cs:line 981
    

    We use some custom code to update the index through the api for TransformingIndexValues(object sender, IndexingItemEventArgs e), but are gettin the Collection was modified error in our foreach of the e.ValueSet.Values. But we do only modify the e.ValueSet.Values with e.ValueSet.TryAdd("key", "value") after the foreach is done and all data is returned.

    So the question is what we can do to make sure the collection aint modified and there after locked and emptied?

  • Adriano Yannelli 1 post 71 karma points
    Mar 09, 2022 @ 18:55
    Adriano Yannelli
    0

    We are experiencing the same issue, every now and then we get the same error from our environments:

       [Error] Error indexing queue items
    System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at Umbraco.Examine.UmbracoExamineIndex.OnDocumentWriting(DocumentWritingEventArgs docArgs) in D:\a\1\s\src\Umbraco.Examine\UmbracoExamineIndex.cs:line 142
       at Examine.LuceneEngine.Providers.LuceneIndex.AddDocument(Document doc, ValueSet valueSet, IndexWriter writer) in D:\a\1\s\src\Examine\LuceneEngine\Providers\LuceneIndex.cs:line 794
       at Examine.LuceneEngine.Providers.LuceneIndex.ProcessIndexQueueItem(IndexOperation op, IndexWriter writer) in D:\a\1\s\src\Examine\LuceneEngine\Providers\LuceneIndex.cs:line 1334
       at Examine.LuceneEngine.Providers.LuceneIndex.ProcessQueueItem(IndexOperation item, IndexWriter writer) in D:\a\1\s\src\Examine\LuceneEngine\Providers\LuceneIndex.cs:line 1133
       at Examine.LuceneEngine.Providers.LuceneIndex.ForceProcessQueueItems(Boolean block) in D:\a\1\s\src\Examine\LuceneEngine\Providers\LuceneIndex.cs:line 981
    

    Our version of Umbraco is 8.16.0

  • Bo Jacobsen 590 posts 2366 karma points
    Mar 28, 2022 @ 10:22
    Bo Jacobsen
    0

    Hi Adriano.

    We reduced the errors of these types by making the e.ValueSet.Values to a list like this:

    var newValue = string.Empty;
    
    var valueSetValues = e.ValueSet.Values.ToList();
    foreach(var fieldValues in valueSetValues)
    {
        foreach(object value in fieldValues.Value)
        {
            newValue += value.ToString();
        }
    }
    
    if(!e.ValueSet.TryAdd("someKey", newValue))
    {
        // Log or something..
    }
    

    I guess its because .ToList() makes a copy of the object.

    However we do still get these errors from time to time, but not very often.

Please Sign in or register to post replies

Write your reply to:

Draft