Re: relation ### modified while in use

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: relation ### modified while in use
Дата
Msg-id 4088.972278867@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: relation ### modified while in use  (Alex Pilosov <alex@pilosoft.com>)
Список pgsql-hackers
Alex Pilosov <alex@pilosoft.com> writes:
> On Mon, 23 Oct 2000, Tom Lane wrote:
>> begin;
>> select * from foo;  -- gets AccessShareLock
>> LOCK TABLE foo;        -- gets AccessExclusiveLock
>> ...
>> end;
>> 
>> this will work currently because the SELECT releases AccessShareLock
>> when done, but it will deadlock if SELECT does not release that lock.

> Probably a silly question, but since this is the same transaction,
> couldn't the lock be 'upgraded' without a problem? 

No, the problem happens when two transactions do the above at about
the same time.  After the SELECTs, both transactions are holding
AccessShareLock, and both are waiting for the other to let go so's they
can get AccessExclusiveLock.  AFAIK any concept of "lock upgrade" falls
afoul of this basic deadlock risk.

We do have a need to be careful that the system doesn't try to do
lock upgrades internally.  For example, inLOCK TABLE foo;
the parsing step had better not grab AccessShareLock on foo in
advance of the main execution step asking for AccessExclusiveLock.
        regards, tom lane


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

Предыдущее
От: Alex Pilosov
Дата:
Сообщение: Re: relation ### modified while in use
Следующее
От: Philip Warner
Дата:
Сообщение: Re: relation ### modified while in use