Skip site navigation (1) Skip section navigation (2)

BUG #3708: Ongoing transactin that involves the table containing foreign key blocks updates of referenced table

From: "Maksym Sobolyev" <sobomax(at)sippysoft(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3708: Ongoing transactin that involves the table containing foreign key blocks updates of referenced table
Date: 2007-10-30 07:22:15
Message-ID: 200710300722.l9U7MFmr069499@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      3708
Logged by:          Maksym Sobolyev
Email address:      sobomax(at)sippysoft(dot)com
PostgreSQL version: 8.0.14
Operating system:   FreeBSD 6.2-RELEASE
Description:        Ongoing transactin that involves the table containing
foreign key blocks updates of referenced table
Details: 

For some reason ongoing INSERT transaction that involves the table
containing foreign key blocks updates of the table being referenced even in
the case when those updates on referenced table don't touch the key value
itself. There is no obvious reason for such behavior.

Let's consider we have the following simple schema:

create table a (a_idx bigint, data int);
alter table a add constraint a_pkey primary key(a_idx);
create table b (b_idx bigint, a_idx bigint);
alter table b add constraint "$1" foreign key (a_idx) references a(a_idx);
insert into a values (1, NULL);

Now, let's start two parallel connections to the DB, say in two shell
windows:

---- Session 1 begins ----
BEGIN;
insert into b values (1, 1);
---- Session 1 stays idle ----

---- Session 2 begins ----
update a set data=5;
---- Session 2 blocks ----

As you can see at the end the UPDATE in session 2 is blocked until
transaction in session 1 either commits or rolls back. However, as I said
there is no reason for this blockage since update in the session 2 doesn't
involve foreign key a_idx, so that whatever outcome of the transaction in
session 1 would be there is no interdependency and update in session 2
should be allowed to proceed.

-Maxim

pgsql-bugs by date

Next:From: Vishesh JainDate: 2007-10-30 07:35:42
Subject: BUG #3709: Changing Table Owner
Previous:From: Tom LaneDate: 2007-10-30 04:09:03
Subject: Re: Possible planner bug/regression introduced in 8.2.5

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group