Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 401F99FA240 for ; Wed, 18 Oct 2006 12:28:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 32617-07 for ; Wed, 18 Oct 2006 12:28:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id CB8329FB26E for ; Wed, 18 Oct 2006 12:28:27 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Wed, 18 Oct 2006 15:28:20 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 18 Oct 2006 10:28:20 -0500 Subject: Re: ACCESS EXCLUSIVE lock From: Scott Marlowe To: Atesz Cc: pgsql-performance@postgresql.org In-Reply-To: <4536391E.7040604@ritek.hu> References: <4536391E.7040604@ritek.hu> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1161185300.8706.82.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 18 Oct 2006 10:28:20 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.077 tagged_above=0 required=5 tests=AWL, SPF_PASS, UNPARSEABLE_RELAY, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200610/359 X-Sequence-Number: 21488 On Wed, 2006-10-18 at 09:24, Atesz wrote: > Hi! > > I have a problem with ACCESS EXCLUSIVE lock when I drop a reference in > transaction. I have 2 tables: > create table a(id SERIAL primary key); > create table b(id SERIAL primary key references a(id)); > > After that I have 2 processes: P1, P2 > In P1: > begin; > ALTER TABLE b DROP CONSTRAINT b_id_fkey; > > In P2: > SELECT * FROM a; > > And I'm waiting for the result, but I don't get until P1 finishes. > I know the DROP CONSTRAINT put an ACCESS EXCLUSIVE table LOCK into the > TABLE a, and the SELECT is stopped by this LOCK in P2. > Note: I cannot commit the P1 earlier, because it's a very long > transaction (more hours, data conversion transaction) > My question: Why need this strict locking? > > In my opinion there isn't exclusion between the DROP CONSTRAINT and the > SELECT. What if, a minute or two after the drop contraint, you issue a rollback?