X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8B31647685B for ; Thu, 15 May 2003 14:22:44 -0400 (EDT) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with ESMTP id 66203-01 for ; Thu, 15 May 2003 14:22:13 -0400 (EDT) Received: from ms-smtp-02.texas.rr.com (ms-smtp-02.texas.rr.com [24.93.36.230]) by postgresql.org (Postfix) with ESMTP id A49FD47685F for ; Thu, 15 May 2003 12:59:45 -0400 (EDT) Received: from spaceship.com (cs24243211-239.austin.rr.com [24.243.211.239]) by ms-smtp-02.texas.rr.com (8.12.5/8.12.2) with ESMTP id h4FGxinV002618; Thu, 15 May 2003 11:59:44 -0500 (CDT) Message-ID: <3EC3C77A.3010006@spaceship.com> Date: Thu, 15 May 2003 11:59:38 -0500 From: Matt Mello User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4a) Gecko/20030401 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: "deadlock detected" documentation References: <3EB82DA1.7020809@spaceship.com> <24809.1052282819@sss.pgh.pa.us> <3EC32935.5040005@spaceship.com> <7737.1053003625@sss.pgh.pa.us> <3EC3C239.7070708@spaceship.com> <10096.1053017383@sss.pgh.pa.us> In-Reply-To: <10096.1053017383@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/330 X-Sequence-Number: 13495 Tom Lane wrote: > You are probably getting deadlocks on the rows referenced by the foreign > keys, then. As of the current release, each UPDATEd row will cause the > foreign-key triggers to grab a row lock (SELECT FOR UPDATE lock) on the > referenced row in the other table. If you have concurrent updates > touching rows that reference the same other-table rows, it's possible to > get a deadlock depending on the order in which the updates happen to > occur. > There is a patch in CVS tip that alleviates the problem substantially > by not taking a foreign-table lock when the foreign key value isn't > being changed by the UPDATE, which is commonly the case (although I'm > not entirely sure that it will help you, since you do seem to be > updating the referencing column). If you want to try it, I believe Jan > Wieck posted a 7.3 version of the patch a month or so ago. I see. One item I forgot to mention ... Both update statements have a where clause containing txn.terminalid=38. Txn.terminalid is a foreign key column in that table (txn.terminalid->terminal.terminalid). Could this be the source of the trouble? If so, I can work around this for now, but the patch you mention sounds like it would work in almost all situations where this might adversely (and unexpectedly) affect us. Thanks! -- Matt Mello