Re: Tracking down a deadlock

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bill Moseley <moseley(at)hank(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Tracking down a deadlock
Date: 2009-05-04 01:08:29
Message-ID: 6605.1241399309@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bill Moseley <moseley(at)hank(dot)org> writes:
> Then when I run the test script (which runs the same transaction in two
> processes at the same time) and get a deadlock the same query is shown twice
> both with "waiting" set true:

> UPDATE account set foo = 123 where id = $1

> And if I remove that update from the transaction I no longer have the deadlock.
> So, it seems like that is the problem update.

> Is postgresql telling me that it's deadlocked on two transactions trying to run
> that same update?

Looks like it.

> There are no other updates to that account table in the transaction, so I'm
> confused how that is causing a deadlock.

Is there more than one row with the target id? Does the account table
have any foreign-key references to or from it? It's sometimes possible
to get a deadlock associated with trying to lock FK-referenced rows that
several updated rows have in common.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moseley 2009-05-04 05:02:40 Re: Tracking down a deadlock
Previous Message Bill Moseley 2009-05-04 00:50:09 Re: Tracking down a deadlock