public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Shaheed Haque <[email protected]>
Cc: pgsql-general list <[email protected]>
Subject: Re: Unexpected deadlock across two separate rows, using Postgres 17 and Django's select_for_update()
Date: Sat, 07 Mar 2026 06:45:29 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAHAc2jd=x-6hM=CoEYOaJ6ST5p-nGkTxDmh=PrwxacnkUp=31A@mail.gmail.com>
References: <CAHAc2jd=x-6hM=CoEYOaJ6ST5p-nGkTxDmh=PrwxacnkUp=31A@mail.gmail.com>
Shaheed Haque <[email protected]> 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
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: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Unexpected deadlock across two separate rows, using Postgres 17 and Django's select_for_update()
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox