[openstack-dev] Question about locking

Ben Nemec openstack at nemebean.com
Fri Jun 28 19:57:31 UTC 2013


On 2013-06-26 12:07, Rosa, Andrea (HP Cloud Services) wrote:
> Hi all,
> 
> What happens if a greenthread, after acquiring a lock  (not external), 
> it dies?
> For example:
> A thread is performing the "do_terminate_instance", it has the lock
> and before terminating the process it dies,  what happens at the lock?
> Is that released in some way?

That function is using the synchronized decorator, which means that it's 
wrapped by a semaphore context.  As I understand it (and someone correct 
me if I'm wrong), if an error happens and an exception is thrown the 
context would be exited and the semaphore released.  Of course, I 
suppose there are situations where a thread could be terminated without 
being able to do that cleanup, but I suspect most of those cases would 
kill the entire process, making the lock irrelevant (since you specify 
not external).

> If  not I think that all other actions for that instance are blocked
> waiting for the lock, is that correct?

That is a potential pitfall of synchronization, but I think it shouldn't 
happen in this case.  Are you seeing this behavior?

-Ben



More information about the OpenStack-dev mailing list