X-Original-To: pgsql-admin@postgresql.org Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 850914760CC for ; Fri, 7 Mar 2003 02:42:38 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A1194D621; Thu, 6 Mar 2003 23:42:38 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 96D4C5C0A; Thu, 6 Mar 2003 23:42:38 -0800 (PST) Date: Thu, 6 Mar 2003 23:42:38 -0800 (PST) From: Stephan Szabo To: "A.Bhuvaneswaran" Cc: Subject: Re: deadlock detected during insert In-Reply-To: Message-ID: <20030306233843.A88165-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200303/58 X-Sequence-Number: 7706 On Fri, 7 Mar 2003, A.Bhuvaneswaran wrote: > > > If you're using foreign keys on the table that you're inserting into it's > > possible that it's waiting on another transaction doing an insert to the > > same key or on a change to the referenced table. > > 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. > BTW, do we have any link about deadlock detection during insert command as > we have for update command? Not sure really.