X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7830E9DCD42 for ; Fri, 2 Dec 2005 16:46:08 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22003-01 for ; Fri, 2 Dec 2005 16:46:05 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id ECD359DCAE2 for ; Fri, 2 Dec 2005 16:46:05 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jB2Kk6P7006888; Fri, 2 Dec 2005 15:46:07 -0500 (EST) To: "Francesco Formenti - TVBLOB S.r.l." cc: pgsql-general@postgresql.org Subject: Re: [Fwd: Re: deadlock on the same relation] In-reply-to: <4390893D.4070109@tvblob.com> References: <4390893D.4070109@tvblob.com> Comments: In-reply-to "Francesco Formenti - TVBLOB S.r.l." message dated "Fri, 02 Dec 2005 18:49:49 +0100" Date: Fri, 02 Dec 2005 15:46:06 -0500 Message-ID: <6887.1133556366@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.002 required=5 tests=[AWL=0.002] X-Spam-Score: 0.002 X-Spam-Level: X-Archive-Number: 200512/133 X-Sequence-Number: 87696 "Francesco Formenti - TVBLOB S.r.l." 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