Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F0B964758BD for ; Mon, 13 Jan 2003 20:01:17 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 5DCC3475461 for ; Mon, 13 Jan 2003 20:01:17 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 53B55D60A; Mon, 13 Jan 2003 17:01:20 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 455BF5C02; Mon, 13 Jan 2003 17:01:20 -0800 (PST) Date: Mon, 13 Jan 2003 17:01:20 -0800 (PST) From: Stephan Szabo To: Andrew Biagioni Cc: Subject: Re: Deadlock Checker doesn't see foreign-key locks In-Reply-To: <3E23593E.2060305@e-greek.net> Message-ID: <20030113165729.N62212-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/136 X-Sequence-Number: 6978 On Mon, 13 Jan 2003, Andrew Biagioni wrote: > It appears to me that the Deadlock Checker doesn't see (and thus > release) foreign-key-based locks (see below for details). Am I missing > something? Is there a configuration item I am unaware of? We're going to need a runnable example, I'm not 100% sure which tables are referencing which other tables and how given the text below. I have gotten deadlock messages from the foreign keys in the past though. > HOWEVER, if I have a foreign-key-related lock, as follows, it is not > recognized: > > Thread A: BEGIN WORK; > UPDATE [table A, row W] > /* This has a foreign key into table F, row P */ > > Thread B: BEGIN WORK; > UPDATE [table B, row Y] > /* This has a foreign key into table G, row Q */ > > Thread A: UPDATE [table B, row Z] > /* This has a foreign key into table F, row P */ > > Thread B: UPDATE [table A, row X] > /* This has a foreign key into table G, row Q */ > > Note that none of the UPDATEs step on the same actual row of the same > table, but they step (and lock) the same rows in the same tables via > foreign keys. > > In this case (specifically tested), there is no deadlock detection. Do you get a deadlock? Given the text above, I wouldn't expect one since both transactions have the locks already when the second request for the same lock comes in (unless you meant to swap A and B in the bottom two).