pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matt Mello <alien@spaceship.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: "deadlock detected" documentation
Date: Thu, 15 May 2003 14:06:36 -0500
Message-ID: <3EC3E53C.9070800@spaceship.com> (raw)
In-Reply-To: <10286.1053018824@sss.pgh.pa.us>
References: <3EB82DA1.7020809@spaceship.com>
	<24809.1052282819@sss.pgh.pa.us>
	<3EC32935.5040005@spaceship.com>
	<7737.1053003625@sss.pgh.pa.us>
	<3EC3C239.7070708@spaceship.com>
	<10096.1053017383@sss.pgh.pa.us>
	<3EC3C77A.3010006@spaceship.com>
	<10286.1053018824@sss.pgh.pa.us>

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




view thread (13+ messages)  latest in thread

Message-ID: <3EC3E53C.9070800@spaceship.com>
Permalink:  ../3EC3E53C.9070800@spaceship.com/
Also on:    postgresql.org/message-id/3EC3E53C.9070800@spaceship.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: alien@spaceship.com, tgl@sss.pgh.pa.us
  Subject: Re: "deadlock detected" documentation
  In-Reply-To: <3EC3E53C.9070800@spaceship.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox