Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F1E1B475B8F for ; Tue, 14 Jan 2003 18:56:25 -0500 (EST) Received: from proteus.affordablehost.com (unknown [216.46.203.177]) by postgresql.org (Postfix) with SMTP id 52525475E20 for ; Tue, 14 Jan 2003 18:56:25 -0500 (EST) Received: (qmail 1819 invoked from network); 14 Jan 2003 23:57:01 -0000 Received: from unknown (HELO e-greek.net) (66.92.74.97) by 216.46.203.177 with SMTP; 14 Jan 2003 23:57:01 -0000 Message-ID: <3E24A3AE.2000903@e-greek.net> Date: Tue, 14 Jan 2003 18:56:30 -0500 From: Andrew Biagioni User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stephan Szabo Cc: pgsql-admin@postgresql.org Subject: Re: Deadlock Checker doesn't see foreign-key locks References: <20030113165729.N62212-100000@megazone23.bigpanda.com> Content-Type: multipart/alternative; boundary="------------000306020402040708000108" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/153 X-Sequence-Number: 6995 --------------000306020402040708000108 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Stephan Szabo wrote: >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. > > I tried to create a runnable example, and as it turns out I can't reproduce the problem in a proof-of-concept configuration. I'll have to do some more homework to determine the REAL scenario in which my problem occurs (and thus, the real cause of the problem). > > >>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). > > Thanks, Andrew > > --------------000306020402040708000108 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Stephan Szabo wrote:
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.
  

I tried to create a runnable example, and as it turns out I can't reproduce the problem in a proof-of-concept configuration.  I'll have to do some more homework to determine the REAL scenario in which my problem occurs (and thus, the real cause of the problem).
  
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).
  

Thanks,

                Andrew

  
--------------000306020402040708000108--