From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Francesco Formenti - TVBLOB S(dot)r(dot)l(dot)" <francesco(dot)formenti(at)tvblob(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [Fwd: Re: deadlock on the same relation] |
Date: | 2005-12-02 20:46:06 |
Message-ID: | 6887.1133556366@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Francesco Formenti - TVBLOB S.r.l." <francesco(dot)formenti(at)tvblob(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Jaime Casanova | 2005-12-02 20:48:23 | Re: accessing text of the query in a rule |
Previous Message | Bruce Momjian | 2005-12-02 20:44:11 | Re: Numeric 508 datatype |