Re: LOCK TABLE .. DEFERRABLE

Поиск
Список
Период
Сортировка
От Simon Riggs
Тема Re: LOCK TABLE .. DEFERRABLE
Дата
Msg-id CANP8+j+8SXmC+bEvuffewiLdob3KjxyfpnY+8uJoy=j6=fg-yw@mail.gmail.com
обсуждение исходный текст
Ответ на LOCK TABLE .. DEFERRABLE  (Rod Taylor <rod.taylor@gmail.com>)
Ответы Re: LOCK TABLE .. DEFERRABLE  (Andres Freund <andres@anarazel.de>)
Re: LOCK TABLE .. DEFERRABLE  (Rod Taylor <rod.taylor@gmail.com>)
Список pgsql-hackers
On 5 April 2016 at 17:43, Rod Taylor <rod.taylor@gmail.com> wrote:
The intention of this feature is to give the ability to slip into a normal workload for non-urgent maintenance work. In essence, instead of lock waiters being in a Queue, DEFERRABLE causes the current lock statement to always be last.

Good idea; this was on my list of things to implement. I was going to call it WAIT PATIENTLY option.
 
It was discussed at last years pgCon as useful for replication tools adding/removing triggers. I've also seen more than one plpgsql loop using subtransactions and LOCK TABLE .. NOWAIT to achieve a similar effect. IMO, it's much cleaner built in.

Agreed, but your implementation is essentially just the same looping concept, which I don't much like.
 
If a lock is successfully obtained on one table, but not on all tables, it releases that lock and will retry to get them as a group in the future. Since inheritance acts as a group of tables (top + recursive cascade to children), this implementation is necessary even if only a single table is specified in the command.

I'd prefer to see this as a lock wait mode where it sits in the normal lock queue BUT other lock requestors are allowed to queue jump past it. That should be just a few lines changed in the lock conflict checker and some sleight of hand in the lock queue code.

That way we avoid the busy-wait loop and multiple DEFERRABLE lock waiters queue up normally.

--
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

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

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: [PATH] Jsonb, insert a new value into an array at arbitrary position
Следующее
От: Andres Freund
Дата:
Сообщение: Re: LOCK TABLE .. DEFERRABLE