1

Closed

StorageCache is not thread safe

description

Andrea,
My web application is having some race conditions. I dived deep into StorageCache class. I believe I have found the cause:
itemResultCache, attributesResultCache and ldapQueryResults are shared across all threads.
In a web application, StorageCache object is a singleton and shared across all threads. But itemResultCache, attributesResultCache and ldapQueryResults are really meant to be used only by one thread (single call).
In my case, when CheckAccess->storeApplicationItemValidation is called, the following two lines are executed:
        this.itemResultCache = Hashtable.Synchronized(new Hashtable());
        this.attributesResultCache = Hashtable.Synchronized(new Hashtable());
After that, all the threads are looking at two empty caches. All the data is lost.
 
Suggestion: Make these cache objects to be thread data or CallContext data.
 
It's an urgent issue on our side, please let me know your time line ASAP. I may need do some custom coding.
 
Thanks!
 
Richard
Closed Feb 2, 2012 at 3:24 AM by tangrl

comments

aferende wrote Jan 29, 2012 at 8:46 AM

Hi Richard,
could you make the suggested code changes ?
If you want, I can add you as developer.

Let me know.
Andrea.

tangrl wrote Jan 30, 2012 at 2:43 PM

Andrea,
Sure, I can make the changes and test it here first. Please add me as a developer and let me know the best way to send you the code changes.

Thanks!

Richard

aferende wrote Jan 30, 2012 at 9:18 PM

I added you as a Team Developer.
To make changes please use Visual Studio 2010 connected with Team Explorer.
See here: http://codeplex.codeplex.com/wikipage?title=Using%20TFS%20and%20Team%20Explorer%20with%20CodePlex

Ty,
Andrea.

wrote Feb 2, 2012 at 3:24 AM

Resolved with changeset 73899.