pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John A Meinel <john@arbash-meinel.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: Odd Locking Problem
Date: Thu, 11 Aug 2005 16:11:58 -0500
Message-ID: <42FBBF1E.6040403@arbash-meinel.com> (raw)
In-Reply-To: <20050811210842.GA28253@alvh.no-ip.org>
References: <42FBB6CF.6000404@arbash-meinel.com>
	<20050811210842.GA28253@alvh.no-ip.org>

Alvaro Herrera wrote:
> 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
>

Actually, there are but the insert is occurring into table 'a' not table
'b'.
'a' refers to other tables, but these should not be modified.

>
> 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);

I'll try one of the CVS entries and see if it happens there. Good to
hear there has been work done.

John
=:->

>

Attachments:

  signature.asc (application/pgp-signature, 252B) download

view thread (5+ messages)  latest in thread

Message-ID: <42FBBF1E.6040403@arbash-meinel.com>
Permalink:  ../42FBBF1E.6040403@arbash-meinel.com/
Also on:    postgresql.org/message-id/42FBBF1E.6040403@arbash-meinel.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: john@arbash-meinel.com, alvherre@alvh.no-ip.org
  Subject: Re: Odd Locking Problem
  In-Reply-To: <42FBBF1E.6040403@arbash-meinel.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox