Re: "deadlock detected" documentation - Mailing list pgsql-sql

From Matt Mello
Subject Re: "deadlock detected" documentation
Date
Msg-id 3EC3E53C.9070800@spaceship.com
Whole thread Raw
In response to Re: "deadlock detected" documentation  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: "deadlock detected" documentation  (Matt Mello <alien@spaceship.com>)
List pgsql-sql
Okay, so one last question on this...

If I do the following, assuming I haven't applied the patch, will it 
still result in a deadlock (in other words, does this only happen with 
multi-record updates, or can it happen with independent single-record 
updates inside transactions)?

THREAD1:                                                THREAD2:

BEGIN;
update txn set ... where txn.terminalid = 1;
                                                          BEGIN;                    update txn set ... where
txn.terminalid= 2;
 

(I anticipate the next statement will give me a deadlock.)

update txn set ... where txn.terminalid = 2;
                    update txn set ... where txn.terminalid = 1;
COMMIT;
                                                         COMMIT;

Thanks, again!


Tom Lane wrote:
> Matt Mello <alien@spaceship.com> writes:
> 
>>I see.  One item I forgot to mention ...  Both update statements have a 
>>where clause containing txn.terminalid=38.  Txn.terminalid is a foreign 
>>key column in that table (txn.terminalid->terminal.terminalid).  Could 
>>this be the source of the trouble?
> 
> 
> Not per se.  The problem depends on which rows get updated and in what
> sequence --- the contents of the WHERE clause aren't the issue, except
> insofar as they determine the set of rows to be updated.
> 
>             regards, tom lane
> 
> 

-- 
Matt Mello
512-350-6900



pgsql-sql by date:

Previous
From: Alvar Freude
Date:
Subject: Re: SQL Parser
Next
From: "Cyber Join"
Date:
Subject: select 3 characters