[openstack-dev] [oslo][concurrency] lockutils lock fairness / starvation

Chris Friesen chris.friesen at windriver.com
Tue May 16 19:28:15 UTC 2017


On 05/16/2017 10:45 AM, Joshua Harlow wrote:
> So fyi,
>
> If you really want something like this:
>
> Just use:
>
> http://fasteners.readthedocs.io/en/latest/api/lock.html#fasteners.lock.ReaderWriterLock
>
>
> And always get a write lock.
>
> It is a slightly different way of getting those locks (via a context manager)
> but the implementation underneath is a deque; so fairness should be assured in
> FIFO order...

That might work as a local patch, but doesn't help the more general case of fair 
locking in OpenStack.  The alternative to adding fair locks in oslo would be to 
add fairness code to all the various OpenStack services that use locking, which 
seems to miss the whole point of oslo.

In the implementation above it might also be worth using one condition variable 
per waiter, since that way you can wake up only the next waiter in line rather 
than waking up everyone only to have all-but-one of them go back to sleep right 
away.

Chris




More information about the OpenStack-dev mailing list