← Back to team overview

maas-devel team mailing list archive

Re: Race in Node.acquire()?

 

On 04/30/2014 10:24 AM, Raphaël Badin wrote:

>> I am left wondering if this is anything to do with Django's useless
>> default DB isolation level?

Yes, it is.  And Django designed its house on top of that foundation, so
we change it at our peril.


> Although AFAIK Django doesn't support optimistic locking, there is
> support —since Django 1.4— for pessimistic locking which I think is what
> we should be explicitly using here to protect such a critical code path
> (https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-for-update).

That would do it.  We'd want to avoid blocking on it though, so we'd
need to pass “nowait” and back off to a second choice if the lock failed.

All the while, of course, being careful not to lock a bunch of other
nodes by accident.


Jeroen


Follow ups

References