Deadlocks when using caching application block?

Topics: Caching Application Block
Aug 9, 2010 at 7:49 PM

Hello,

An ASP.NET 3.5 application we are using appears to be deadlocking at times when attempting to pull an item from the cache. This then causes the app to hang and users to suffer... I was able to capture this within a memory dump, and want to know if this is expected to happen sometimes, and if the newest version would fix the problem?  (I believe we are a couple versions behind, but I am not sure of which version specifically)

In windbg, using the SOSEX module to scan for deadlocks, I see the following. When I looked at the !runaway threads, all the tops threads were doing this same monitor/wait for a lock action.

0:029> .load e:\debugging\modules\sosex.dll

0:029> !dlk

Examining SyncBlocks...

Scanning for ReaderWriterLocks...

Scanning for lock holders on ReaderWriterLocks...

Scanning for threads waiting on SyncBlocks...

*** ERROR: Module load completed but symbols could not be loaded for Microsoft.ApplicationBlocks.Cache.DLL

Scanning for threads waiting on ReaderWriterLocks...

Deadlock detected:

CLR Thread 0x1 is waiting for orphaned SyncBlock 0014cddc OBJ:033c65b0[Microsoft.ApplicationBlocks.Cache.CacheManager]

The lock was orphaned by an unknown managed thread, which has since terminated.

CLR Thread 0x1 is waiting at Microsoft.ApplicationBlocks.Cache.CacheManager.GetItem(System.String)(+0x65 IL)(+0x15d Native)

 

Deadlock detected:

CLR Thread 0x8 is waiting for orphaned SyncBlock 0014cddc OBJ:033c65b0[Microsoft.ApplicationBlocks.Cache.CacheManager]

The lock was orphaned by an unknown managed thread, which has since terminated.

CLR Thread 0x8 is waiting at Microsoft.ApplicationBlocks.Cache.CacheManager.GetItem(System.String)(+0x65 IL)(+0x15d Native)

 

Deadlock detected:

CLR Thread 0xd is waiting for orphaned SyncBlock 0014cddc OBJ:033c65b0[Microsoft.ApplicationBlocks.Cache.CacheManager]

The lock was orphaned by an unknown managed thread, which has since terminated.

CLR Thread 0xd is waiting at Microsoft.ApplicationBlocks.Cache.CacheManager.GetItem(System.String)(+0x65 IL)(+0x15d Native)

 

Deadlock detected:

CLR Thread 0x20 is waiting for orphaned SyncBlock 0014cddc OBJ:033c65b0[Microsoft.ApplicationBlocks.Cache.CacheManager]

The lock was orphaned by an unknown managed thread, which has since terminated.

CLR Thread 0x20 is waiting at Microsoft.ApplicationBlocks.Cache.CacheManager.GetItem(System.String)(+0x65 IL)(+0x15d Native)

 

4 deadlocks detected.

 

Any help is greatly appreciated.. we're already planning to upgrade to the newest version, but in case this might be caused by a poor implementation I thought I would pose the question.

Thanks!

-Matt

Aug 10, 2010 at 9:03 AM

Hi Matt,

Unfortunately I have no any way to try and reproduce your scenario to be able to suggest anything with the implementation since your entlib version seems quite pretty old :-)

Only one thing I can think of regarding your problem is to check if implementing locking would be necessary in your application with the caching block code to make sure it is thread safe.

Anyway, if you plan to upgrade to the latest entlib version as far as I know the caching block is thread-safe. You might also want to check this post (though this is prior to the release of EntLib 5) Caching Block Guidance which may provide some helpful insights too.

Another thing to note is this one Rethink decision of deprecating caching block.

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Aug 10, 2010 at 1:18 PM

Thanks for your response, Gino.

I'm certainly not asking anyone to go through trying to reproduce this, especially with the lack of detail i've provided regarding version and implementation of our wrapper classes.... I've never seen any other questions regarding this scenario, so I think we'll try the new version and see what we get. 

 

The link about possibly deprecating the caching block was good to know.. 

-Matt

Aug 11, 2010 at 5:36 AM
Based on the namespaces in the trace you gave below, you aren't using Entlib at all - you're using the old, old, OLD standalone caching block from before Entlib even existed as a single thing. As such, my first suggestion would be to upgrade; there's been a lot of improvements and bug fixes in the last six years.