I originally posted about this issue in the General ASP.NET forum [reference], but have isolated the problem to a conflict with IIS Web Gardens and so I'm cross-posting it here.
Summary: My application works as expected when used with a single worker process. When shared between multiple worker processes, however, one process (presumably the first) behaves as expected, where as the second exhibits problems which seem related to thread management. There are two specific cases.
-
CurrentUICulture. I have a custom cache parameter based on Thread.CurrentUICulture. One of the worker processes interprets this properly (returning a cache snapshot for each unique UICulture). The second always returns the first snapshot created (regardless of which UICulture it was created for or which is requested).
-
Synchronized Hashtable. I have a custom business object which exposes a Hashtable as a public static member (should be threadsafe). Additionally, it implements synchronization to avoid potential conflicts during multiple writes. The object works as expected on one worker process; on the other, however, it exhibits indications of multi-threading violations (e.g., there are version conflicts which suggest overwritten states).
I understand that this behavior is hard to isolate w/out code samples. Given, however, that the code operates as expected in a single worker process environment I am interested in direction on what impact web gardens might have on threading issues, especially thread safety (I could speculate how the first issue could be a multi-threading violation based on how .NET potentially stored its OutputCache index).
I've worked around this issue by disabling web gardening on the server. However, I'd like to understand the core issue and, ideally, make the application more environment-agnostic. Any suggestions on where to start digging would be appreciated.