1
Vote

Concurrency requests problem

description

Hi,
First of all, thanks for the great package!!!

I integrated the package in our web application – http://central.greenroad.com
Some time ago our users started to report us about lack of some resource on the pages like lack of CSS or JS files. The problem occurred consistently after recycling the application.
I successfully reproduce it on my development environment by:
• Recycle application pool (IIS 7)
• Press ‘F5’ on one browser instance (IE for example)
• Press ‘F5’ on the other browser instance (FF for example)
Result: one of the instances got wrong reference for CSS or/and JS file. You should press ‘F5’ as quick as possible on the both browsers in order to simulate concurrent requests. I added some tracing to your code in order to be sure that requests executed simultaneous, at the same millisecond.

I dug to the package source code and discovered that once you access the HttpContext.Current.Cache object, there is some problems with multithreading. ‘headAnalysis’ variable initializing twice and both threads insert it to the cache. In some case, one of the threads overrides previous object with wrong values. I didn’t realized why, but you can see in the attached file the fix I made with ‘lock’. Looks like it sole our problem (we are using ‘HeadCachingOption = PerPage’).
Please, review the attached file and advise me what to do with other cached objects.
Thanks,
Boris Meerovich

file attachments

comments