Our production servers (.NET 2.0) ran into this exception suddenly a few months ago. It came from a snippet of codes updating Hashtable. Weird enough, the web sites are running for a long while and, and from SVN logs, no evidence shows anyone modified associated codes recently. More strange, the exception appears merely on a couple of web servers.
Even though I've checked with our system administrators that http://support.microsoft.com/
Let's begin the measure that I adopted to tackle it in our environment.
Workaound
Restart IIS - this bothers pretty much our supporting engineers.
Solution
Referring to this thread, a master points out the exception might arise when multiple threads concurrently modify the Hashtable. True enough, our web sites use the Hashtable as a cache, and around 4 threads will modify it quite frequently. So I warp the updating codes around with lock keyword as follows:
readonly static object _sync = new object();
...
lock (_sync)
{
// codes modifying Hashtable
}
After the fix updates to production servers, the exception disappears for more than two weeks, looking like the solution really works out for our environment!
沒有留言:
張貼留言