X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7F4F55648E for ; Thu, 3 Mar 2005 01:24:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61968-08 for ; Thu, 3 Mar 2005 01:24:30 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 94DB956487 for ; Thu, 3 Mar 2005 01:24:29 +0000 (GMT) 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 j231OTfT015717; Wed, 2 Mar 2005 20:24:29 -0500 (EST) To: pg@fastcrypt.com Cc: Mican Bican , pgsql-jdbc@postgresql.org Subject: Re: lock problem when dont commit In-reply-to: <42265BA3.7030509@fastcrypt.com> References: <915cd3880503021437382b001e@mail.gmail.com> <42264B3F.4080409@fastcrypt.com> <15017.1109806796@sss.pgh.pa.us> <42265BA3.7030509@fastcrypt.com> Comments: In-reply-to Dave Cramer message dated "Wed, 02 Mar 2005 19:34:43 -0500" Date: Wed, 02 Mar 2005 20:24:29 -0500 Message-ID: <15716.1109813069@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/26 X-Sequence-Number: 12419 Dave Cramer writes: > Tom Lane wrote: >> Maybe a conflict on referenced foreign-key rows? > can you explain how that happens? When you insert or update a row in a table that has an FK reference, it takes out a row-level lock on the referenced row in the master table. This is needed to prevent someone else from deleting the master row before commit. (Since the someone else can't see your uncommitted row, nothing but a lock could stop them from thinking it's OK to remove the master row.) So if two sessions are trying to insert rows that reference the same master row, they conflict --- because the only type of row-level lock we have at the moment is exclusive. I believe Alvaro is looking into supporting shared row-level locks for 8.1, which'd make this problem go away. regards, tom lane