Re: Tracking down a deadlock - Mailing list pgsql-general

From Tom Lane
Subject Re: Tracking down a deadlock
Date
Msg-id 6605.1241399309@sss.pgh.pa.us
Whole thread Raw
In response to Re: Tracking down a deadlock  (Bill Moseley <moseley@hank.org>)
Responses Re: Tracking down a deadlock
List pgsql-general
Bill Moseley <moseley@hank.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

pgsql-general by date:

Previous
From: Bill Moseley
Date:
Subject: Re: Tracking down a deadlock
Next
From: PostGre Newbie
Date:
Subject: Re: Online Backups PostGre