Deadlock Checker doesn't see foreign-key locks

From: Andrew Biagioni <andrew(dot)biagioni(at)e-greek(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Subject: Deadlock Checker doesn't see foreign-key locks
Date: 2003-01-14 00:26:38
Message-ID: 3E23593E.2060305@e-greek.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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?

As far as I can tell (yes, I tested thoroughly) if I create a normal
deadlock situation as follows, the deadlock detector will work properly:

Thread A: BEGIN WORK;
UPDATE [table A, row X]

Thread B: BEGIN WORK;
UPDATE [table B, row Y]

Thread A: UPDATE [table B, row Y]

Thread B: UPDATE [table A, row X]

This is recognized by the deadlock detector (after the specified delay),
one of the two is rolled back, and the other completes happily.

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.

NOTE - I am currently using v7.2.1, although my search through the
release notes lead me to believe that the problem was not addressed
subsequently.

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Stephan Szabo 2003-01-14 01:01:20 Re: Deadlock Checker doesn't see foreign-key locks
Previous Message Andrew Biagioni 2003-01-14 00:09:14 Deadlock Checker doesn't see foreign-key locks