From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: A.Bhuvaneswaran <bhuvansql@myrealbox.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: deadlock detected during insert
Date: Mon, 10 Mar 2003 08:25:38 -0800 (PST)
Message-ID: <20030310082152.F28512-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0303081027200.1045-100000@Bhuvan.bksys.co.in>
On Sat, 8 Mar 2003, A.Bhuvaneswaran wrote:
>
> > > Can you able to give some test cases? Here i have tried, but unable to
> > > detect deadlock.
> >
> > Not a complete or tested example, but:
> > create table a (a int primary key);
> > create table b ( b int references a);
> > insert into a values (1);
> > insert into a values (2);
> > Transaction 1: begin;
> > Transaction 2: begin;
> > Transaction 1: insert into b values (1);
> > Transaction 2: insert into b values (2);
> > Transaction 1: insert into b values (2);
> > Transaction 2: insert into b values (1);
> >
> > - This really shouldn't be a deadlock, but given the locking level the
> > foreign keys currently use I'm pretty sure it'd cause one.
>
> It shouldn't be, but it is detected. But i am able to eliminate it using
> the lock in share row exclusive mode. Am i right using this lock?
Do you mean you're grabbing a lock with lock table (in a consistent
order)? That'll prevent deadlocks if done consistently although it gives
concurrency problems (serialization of the transactions) which may or may
not be fine for your application.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, bhuvansql@myrealbox.com
Subject: Re: deadlock detected during insert
In-Reply-To: <20030310082152.F28512-100000@megazone23.bigpanda.com>
References: <Pine.LNX.4.44.0303081027200.1045-100000@Bhuvan.bksys.co.in> <20030310082152.F28512-100000@megazone23.bigpanda.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