Re: Unexpected deadlock across two separate rows, using Postgres 17 and Django's select_for_update() - Mailing list pgsql-general

From Tom Lane
Subject Re: Unexpected deadlock across two separate rows, using Postgres 17 and Django's select_for_update()
Date
Msg-id 30226.1772883929@sss.pgh.pa.us
Whole thread Raw
In response to Unexpected deadlock across two separate rows, using Postgres 17 and Django's select_for_update()  (Shaheed Haque <shaheedhaque@gmail.com>)
List pgsql-general
Shaheed Haque <shaheedhaque@gmail.com> writes:
> How can there be a deadlock between updates to different rows (as per the
> bolded WHERE clauses)?

In isolation, there couldn't be ... but you've told us nothing of
what these transactions did beforehand.  The simplest explanation
is that each one is already holding a lock on the row the other
one wants.

Maybe you are not committing between row updates?

If you have no better debugging ideas, try setting log_statements = all
and then examining everything the transactions did up to the failure.

            regards, tom lane



pgsql-general by date:

Previous
From: Shaheed Haque
Date:
Subject: Unexpected deadlock across two separate rows, using Postgres 17 and Django's select_for_update()
Next
From: "David G. Johnston"
Date:
Subject: Re: How to properly use TRIM()?