Re: [Fwd: Re: deadlock on the same relation]

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [Fwd: Re: deadlock on the same relation]
Дата
Msg-id 6887.1133556366@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [Fwd: Re: deadlock on the same relation]  ("Francesco Formenti - TVBLOB S.r.l." <francesco.formenti@tvblob.com>)
Список pgsql-general
"Francesco Formenti - TVBLOB S.r.l." <francesco.formenti@tvblob.com> writes:
> Tom Lane wrote:
>> Probably you have been careless about avoiding "lock upgrade"
>> situations.

> Unfortunately, the first operation I do after the "BEGIN" declaration is
> the LOCK TABLE in access exclusive mode, and is the only explicit lock I
> perform in all the stored procedures.

If you mean that you placed a LOCK TABLE inside the stored procedure,
that's far from being the same thing as the start of the transaction.
For example, if your application does

    BEGIN;
    SELECT * FROM mytab;
    SELECT myprocedure();
    COMMIT;

then by the time control arrives inside myprocedure your transaction
already holds a nonexclusive lock on "mytab".  If you do LOCK TABLE mytab
inside the function then you're risking deadlock.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Reduce NUMERIC size by 2 bytes, reduce max length to 508 digits
Следующее
От: Jaime Casanova
Дата:
Сообщение: Re: accessing text of the query in a rule