Developer forum

Forum » Development » Error when importing

Error when importing

Lars Sørensen
Reply

Hi guys,

 

I'm getting the following error while importing products using the API:

8472700 caused error:Collection was modified; enumeration operation may not execute.   at System.Collections.Hashtable.HashtableEnumerator.MoveNext()
   at Dynamicweb.eCommerce.Frontend.Frontend.DeleteGroupDisplayCache()
   at Dynamicweb.eCommerce.Products.Group.ClearCache(Boolean clearUrlIndex)
   at Dynamicweb.eCommerce.Products.Product.SaveAndConfirm(String ProductID, String ProductVariantID, String ProductLanguageID, Boolean skipExtendedSave)
   at Module.Module.ImportProducts(Entities entities) in c:\Fakepath\Module.cs:line 551<br />
8570911 caused error:Collection was modified; enumeration operation may not execute.   at System.Collections.Hashtable.HashtableEnumerator.MoveNext()

Any idea of, why it occurs and how to avoid it?

BR.

Lars


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Lars,

It would appear that the HttpContext.Current.Items collection is being modified while your import runs. Are you running any other processes with the same HttpContext while you import or are you manipulating the Items collection in any way?

- Jeppe

 

 
Lars Sørensen
Reply

No, it's just one single request. But items? I would have expected something with the group cache:    at Dynamicweb.eCommerce.Frontend.Frontend.DeleteGroupDisplayCache()

 

Br.

Lars

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

DeleteGroupDisplayCache does not manipulate the group cache. It only has to do with the display cache for frontend, i.e., the products being displayed. It is being called from Group.ClearCache though.

The display cache is maintained in HttpContext.Current.Cache, and deleteGroupDisplayCache loops through the elements in the cache and finds the entries that have the correct key. Then it removed those entries from the cache.

There is, however, a bug in that method. Currently, instead of looping through HttpContext.Current.Cache, it loops through the entries in HttpContext.Current.Items. This should not produce the error you're seeing unless the Items collection is being manipulated outside the method at the same time. The method only reads from Items, it does not insert into or remove from it.

- Jeppe

 
Lars Sørensen
Reply

Ok. Well, in the process we're manipulating with products, variants, variant groups, custom fields and options as well as related products and probably other things. But not items isollated.

Br.

Lars

 
Lars Sørensen
Reply

There doesn't seem to be running additional processes when this occurs, and we're not interfering with items. Any suggestions? Is there some caching, we can dump or anything?

BR.

Lars

 
Victor Kozak
Reply

Hi.


Could you share source code (Module.cs), pls (or email to vko@dynamicweb-cms.com)? I'll investigate it.


Regards,
Victor

 
Lars Sørensen
Reply

Thanks, It's on its way to you:)

BR.

Lars

 
Victor Kozak
Reply

Hi.

I have been unable to recreate the problem using your code, but I have fixed the bug that Jeppe mentioned above. This fix will be in our next hotfix.
If you still have the problem after the next hotfix, please let us know, and we'll have to get a copy of the site and look into it again.

Regards,
Victor

 

 
Christian Rud Skovgaard
Reply

The hotfix 8.4.0.21 contains a potential fix for this bug and can be downloaded from http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx

 

Kind regards

Christian

 
Lars Sørensen
Reply

We did the upgrade on the production website, but now a different error occurs:

 

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderVariantCombinations(Product product, Template ParentTemplate, String LoopName)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderProduct(Product Product, Boolean ExtendedProperties, Template Template, Int32 loopCounter, Boolean renderRelated, String productURL, Int32 quantity, Int32 wishListID, Boolean renderPublicList)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderProducts(ProductCollection Products, Template ParentTemplate, String LoopName, Int32 LoopCounter, Boolean renderRelatedProducts, Boolean renderRelatedLists)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderProducts(ProductCollection Products, Template ParentTemplate)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderProducts(ProductCollection Products)
   at Dynamicweb.eCommerce.Frontend.Frontend.ListProducts(ProductCollection products, String groupsIdent, Boolean hasBeenSorted)
   at Dynamicweb.eCommerce.Frontend.Frontend.List(String groups)
   at Dynamicweb.eCommerce.Frontend.Frontend.EcomRender()
   at Dynamicweb.eCommerce.Frontend.Frontend.GetContent()
   at Dynamicweb.Frontend.Content.getModule(DataRow& ParagraphRow)

 

We're running an import, and when the import is done, the index is updated. This error persists throught the index update, and as soon as the update is done, this error is gone.

What's causing it?

BR.

Lars

 
Lars Sørensen
Reply

But actually, this time I ran the index update from MGMT center.

BR.

Lars

 
Lars Sørensen
Reply

Any ideas, guys?

 
Nicolai Høeg Pedersen
Reply

A bug probably.

Will have someone look into it.

BR Nicolai

 
Lars Sørensen
Reply

Excellent, thanks :)

 
Jonas Krarup Dam
Reply

Hi Lars,

We've done some investigating, and found a bug that we believe causes the problem. It turns out you are not the only one who has seen this exception.


bug 15208 has been planned for next sprint, and will be included in a hotfix as soon as possible.

 

Regards, Jonas

 
Lars Sørensen
Reply

Hi Jonas,

Great, thanks. Is it already released, or du you have a time frame for it?

BR.

Lars

 
Lars Sørensen
Reply

I updated the solution to 8.4.1.11, and it seems to have done the trick. Thanks guys:)

 

BR.

Lars

 

You must be logged in to post in the forum