Developer forum

Forum » CMS - Standard features » Sometimes the Column is marked as read only (itemtype)

Sometimes the Column is marked as read only (itemtype)

Sander Veltman
Reply

Hi,

In Dynamic Web we configured an itemtype with some properties for our website

Every night an import proces is executed and the property values of this itemtype are updated.

Sometimes we receive an error "Column is marked read only" when the values are updated. (not every import but random)

On the forum I found a solution by resetting the iis (this works indeed)

Unfortunately whe can't reset the iis before our import proces, because all users are then kicked.

Is there a better solution for this problem?

 

 


Replies

 
Nicolai Pedersen
Reply

Hi Sander

Can you please provide a complete error message and stack?

Thanks, Nicolai

 
Sander Veltman
Reply

Hi Nicolai,

The stack we get is the following.

2017-01-10 10:50:03.9801|ERROR|Jaarbeurs.Shop.Dal.DynamicwebRepositories.AreaRepository|System.Data.ReadOnlyException: Column is marked read only.
   at Dynamicweb.eCommerce.Shops.Shop.set_Name(String Value)
   at Jaarbeurs.Shop.Dal.DynamicwebRepositories.ShopRepository.Update(String shopId, Fair fair, Boolean fullImport)
   at Jaarbeurs.Shop.Dal.DynamicwebRepositories.AreaRepository.Update(Area area, Fair fair, Boolean adbOnly, Boolean fullImport)

Regards Sander

 
Nicolai Pedersen
Reply

Ok, that exception is thrown by the Dynamicweb.eCommerce.Shop instance when it is in a locked state - that happens if you somehow get hold of an instance from the frontend.

Can I see the code that gives you the shop instance?

BR Nicolai

 
Sander Veltman
Reply

Hi Nicolai,

you are correct.

Initially I thought the problem was itemtype related, but after a closer look to our implementation I saw the following.

The fair is our itemtype and in this method we update the shopname and this causes the "Column is marked as read only" error.

So sometimes it is not possible to update the shopname.

What do you mean by "that happens if you somehow get hold of an instance from the frontend"?

Is it when an user is logged in to the website and an user session is locking the shop?

        public void Update(string shopId, Fair fair, bool fullImport)
        {
            _logger.Trace("Update shop: " + shopId );

            var shops = Shops.Shop.getShops(shopId);
            var shop = shops.Single();
            shop.Name = fair.Name;
            shop.Save();

            SetupCatalog(shop, fair, fullImport);
        }

 

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Sander

Our code explicitly locks the shop object from being updated in some scenarioes and keeps that locked shop in the cache. You sometimes get that locked collection back, giving you the exception.

Change to this:

Shops.Shop.ClearCache();
var shops = Shops.Shop.getShops(shopId);
var shop = shops.Single();
shop.Name = fair.Name;
shop.Save();

Maybe only clear cache when the import start - or at least not 1000s times on each import.

BR Nicolai

Votes for this answer: 1
 
Sander Veltman
Reply

Hi Nicolai,

Thank you for your support.

That did the job.

The problem is solved now.

Regards Sander

 

You must be logged in to post in the forum