Re: Atomic operations within spinlocks

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Atomic operations within spinlocks
Дата
Msg-id 1256701.1591297654@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Atomic operations within spinlocks  (Andres Freund <andres@anarazel.de>)
Ответы Re: Atomic operations within spinlocks  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> I'd still like to know which problem we're actually trying to solve
> here. I don't understand the "error" issues you mentioned upthread.

If you error out of getting the inner spinlock, the outer spinlock
is stuck, permanently, because there is no mechanism for spinlock
release during transaction abort.  Admittedly it's not very likely
for the inner acquisition to fail, but it's possible.  Aside from
timeout scenarios (e.g., process holding lock gets swapped out to
Timbuktu), it could be that both spinlocks are mapped onto a single
implementation lock by spin.c, which notes

 * We map all spinlocks onto a set of NUM_SPINLOCK_SEMAPHORES semaphores.
 * It's okay to map multiple spinlocks onto one semaphore because no process
 * should ever hold more than one at a time.

You've falsified that argument ... and no, I don't want to upgrade
the spinlock infrastructure enough to make this OK.  We shouldn't
ever be holding spinlocks long enough, or doing anything complicated
enough inside them, for such an upgrade to have merit.

            regards, tom lane



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Atomic operations within spinlocks
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Atomic operations within spinlocks