X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D9A0E52EE4 for ; Thu, 11 Aug 2005 18:08:30 -0300 (ADT) 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 16618-04 for ; Thu, 11 Aug 2005 21:08:24 +0000 (GMT) Received: from alvh.no-ip.org (200-85-218-206.bk4-dsl.surnet.cl [200.85.218.206]) by svr1.postgresql.org (Postfix) with ESMTP id F160F52E8A for ; Thu, 11 Aug 2005 18:08:21 -0300 (ADT) Received: by alvh.no-ip.org (Postfix, from userid 1000) id C46F6C2D450; Thu, 11 Aug 2005 17:08:42 -0400 (CLT) Date: Thu, 11 Aug 2005 17:08:42 -0400 From: Alvaro Herrera To: John A Meinel Cc: Postgresql Performance Subject: Re: Odd Locking Problem Message-ID: <20050811210842.GA28253@alvh.no-ip.org> Mail-Followup-To: John A Meinel , Postgresql Performance References: <42FBB6CF.6000404@arbash-meinel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <42FBB6CF.6000404@arbash-meinel.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.776 tagged_above=0 required=5 tests=[AWL=0.353, DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/132 X-Sequence-Number: 13879 On Thu, Aug 11, 2005 at 03:36:31PM -0500, John A Meinel wrote: > I'm having an odd case where my system is locking such that if I insert > into a table during a transaction, if I start a new connection and > transaction, it blocks while trying to do a similar insert until the > first transaction is committed or rolled back. Are there foreign keys here? I can duplicate the problem easily with them: -- session 1 create table a (a serial primary key); create table b (a int references a); insert into a values (1); begin; insert into b values (1); -- session 2 insert into b values (1); -- hangs If I commit on session 1, session 2 is unlocked. This is a known problem, solved in 8.1. A workaround for previous releases is to defer FK checks until commit: create table b (a int references a initially deferred); -- Alvaro Herrera () Dios hizo a Adán, pero fue Eva quien lo hizo hombre.