You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by Paul Slater1 <pa...@uk.ibm.com> on 2013/04/26 12:17:44 UTC

BlueprintContainer deadlock

an ABBA deadlock is possible when the BP container locks a ServiceRecipe 
in notifySatisfaction():

Thread A:
notifySatisfaction() locks ServiceRecipe -> unregister() -> 
AbstractServiceReferenceRecipe.serviceChanged -> ReferenceRecipe.untrack 
(tries to lock 'monitor')

Thread B
holds ReferenceRecipe's monitor lock (in bind()) and makes a call to a 
ReferenceListener which in turn invokes the ServiceRecipe locked by Thread 
A (deadlocks possible in decrementActiveCalls, and incrementActiveCalls)

In looking for a solution it seems that imposing a lock hierarchy is very 
difficult. 

The purpose of the lock on ServiceRecipe in notifySatisfaction is not 
clear to me.  It seems it only excludes threads from decrementActiveCalls, 
incrementActiveCalls and quiesce methods of ServiceRecipe which already 
look like they tolerate concurrency with unregister().  It is possible 
that it excludes multiple threads from processing a satisfaction 
notification for the same ServiceRecipe, in which case a different lock 
could be used ?

If there is a current requirement to hold the lock on ServiceRecipe, is it 
possible to use a different lock that would avoid the deadlock ?

I can provide the 2 stacks if required.

thanks

Paul

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU