From: Tom Lane <tgl@sss.pgh.pa.us>
To: Francesco Formenti - TVBLOB S.r.l. <francesco.formenti@tvblob.com>
Cc: pgsql-general@postgresql.org
Subject: Re: [Fwd: Re: deadlock on the same relation]
Date: Fri, 02 Dec 2005 15:46:06 -0500
Message-ID: <6887.1133556366@sss.pgh.pa.us> (raw)
In-Reply-To: <4390893D.4070109@tvblob.com>
References: <4390893D.4070109@tvblob.com>
"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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, francesco.formenti@tvblob.com
Subject: Re: [Fwd: Re: deadlock on the same relation]
In-Reply-To: <6887.1133556366@sss.pgh.pa.us>
References: <4390893D.4070109@tvblob.com> <6887.1133556366@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox