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.
EPiServer Backend Team.
Thanks Paul... I'll have a look through my code and make sure I'm not holding anything anywhere.
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...
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...
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).