Re: releaseOk and LWLockWaitForVar

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: releaseOk and LWLockWaitForVar
Дата
Msg-id 53A857DE.9000900@vmware.com
обсуждение исходный текст
Ответ на releaseOk and LWLockWaitForVar  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-hackers
On 06/17/2014 03:17 PM, Andres Freund wrote:
> LWLockWaitForVar() doesn't set releaseOk to true when waiting
> again. Isn't that a bug?

LWLockWaitForVar() waits in LW_WAIT_UNTIL_FREE mode, because it's not 
interested in acquiring the lock, it just wants to be woken up when it's 
released (or the "var" is updated). LWLockRelease doesn't clear 
releaseOK when it wakes up a LW_WAIT_UNTIL_FREE-mode waiter.

> What if there's another locker coming in after
> LWLockWaitForVar() returns from the PGSemaphoreLock() but before it has
> acquire the spinlock? Now, it might be that it's unproblematic because
> of hte specific way these locks are used right now, but it doesn't seem
> like a good idea to leave it that way.

In that scenario, LWLockWaitForVar() will grab the spinlock, after the 
other process. What happens next depends on the whether the value of the 
variable it guards was changed. If it was, LWLockWaitForVar() will see 
that it changed, and return false without waiting again. If the value 
didn't change, it will sleep until the new locker releases the lock. In 
either case, I don't see a problem with releaseOK. It seems correct as 
it is.

- Heikki




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: API change advice: Passing plan invalidation info from the rewriter into the planner?
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Atomics hardware support table & supported architectures