Issue with multithreaded use of Dynamic Data Store

Vote:
 

Hi all,

I have used the dynamic data store (DDS) as a source for page type ASPXs in a virtual path provider (VPP). This works great until I test the system with more than one user. I know the DDS is not thread safe, and that's fine for my own code because I can lock my CreateStore and GetStore routines. My problem is that, while my VPP is running for a request from user X, the EPiServer.Web.WebControls.Property control (which is being used in my page types) is also using the DDS (for dynamic content I'm guessing) while loading the page for a request of user Y. Once a clash occurs, the whole DDS system becomes unusable until an App Pool Recycle and so I get lots of different errors. I believe the most pertinent error is this one...

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Data.SqlClient.SqlDataReader.GetValueInternal(Int32 i) +215
   System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) +82
   System.Data.SqlClient.SqlDataReader.get_Item(String name) +27
   EPiServer.Data.Dynamic.Providers.DbDataStoreProviderBase.LoadInlineProperties(ProviderCallContext ctx) +126
   EPiServer.Data.Dynamic.Providers.<>c__DisplayClasse`1.<Load>b__d() +19
   EPiServer.Data.Dynamic.Providers.<>c__DisplayClass1`1.<Execute>b__0() +111
   EPiServer.Data.Dynamic.Providers.DbDataStoreProviderBase.InternalExecute(Func`1 method) +55
   EPiServer.Data.Dynamic.Providers.DbDataStoreProviderBase.Execute(Func`1 action) +216
   EPiServer.Data.Dynamic.Providers.DbDataStoreProviderBase.Load(ProviderCallContext context) +215
   EPiServer.Data.Dynamic.DynamicDataStoreBase.InternalLoad(Identity id) +331
   EPiServer.Data.Dynamic.DynamicDataStore`1.Load(Identity id) +51
   EPiServer.Core.PropertySettings.PropertySettingsRepository.TryGetContainer(Guid id, PropertySettingsContainer& propertySettingsContainer) +182
   EPiServer.Core.PropertyData.get_SettingsContainer() +204
   EPiServer.Core.PropertyControlClassFactory.CreatePropertyControl(PropertyData propertyData) +30
   EPiServer.Web.WebControls.Property.CreateChildControls() +269
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +44
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

If this is indeed a problem with simultaneous use of the DDS by my code, and the EPiServer Property control, how do I make sure I do not use the DDS at the same time? There seems to be no synchronisation code in the Property control's use of the DDS, but I might be missing something...

Note:

If I remove the Property control from my page type, the system works perfectly with any number of users.

If I use the Property control through regular VPPs (or just from the file system) that do not use the DDS, the system works perfectly with any number of users (so the Property control doesn't seem to clash with itself).

 

#35297
Dec 03, 2009 11:45
Vote:
 

Hi,

Each instance of a DDS as you say is not threadsafe. You don't need to lock your calls to CreateStore and GetStore as they create a new instance of a DDS class. All shared resources (such as cached metadata) that the DDS uses internally is accessed in a thread safe manner.

You should think of a DDS instance like an ADO.NET connection. Create it, use it and throw it away in a method. Do not keep DDS instances as member variables of a class unless of course you provide locking around use of those instances.

Regarding this particular problem it look like the PropertySettingsRepository is held as a member of an object which is ultimately cached therefore giving this problem.

 

Paul Smith

EPiServer Backend Team.

#35303
Dec 03, 2009 13:03
Vote:
 

Thanks Paul... I'll have a look through my code and make sure I'm not holding anything anywhere.

#35314
Dec 03, 2009 17:06
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.