← Back to team overview

maas-devel team mailing list archive

Re: Race in Node.acquire()?

 

On 30/04/14 23:52, Jeroen Vermeulen wrote:
> On 04/30/2014 02:17 PM, Julian Edwards wrote:
> 
>>> 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.
>>
>> Why can't we block with a timeout, like LP?
> 
> Not a built-in option AFAIK.

Does it need to be built in?  We can set a timeout on PG globally if
necessary, but there surely has to be a middleware change we can use to
set the session timeout.

> And what would we be waiting for?  If the node is locked, it's probably
> because someone else is already allocating it.

Not necessarily, and if that is the case then when the locked thread is
freed it won't see the allocated node due to the query filtering.

> There will be other candidates that aren't locked, so we might as well
> try to grab one of those.  (Or if there aren't, we have to disappoint
> the caller anyway).

Right, so let's discuss more than the first solution that came up and
compare pros and cons before making a choice.

AFAICT, we'd need a retry middleware for pessimistic locking.  We might
need a middleware for PG timeouts unless we go global.

J


Follow ups

References