Re: PostgreSQL's processes blocking each other are not detected as deadlock

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sorin Mircioiu <sorin(dot)mircioiu(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: PostgreSQL's processes blocking each other are not detected as deadlock
Date: 2023-09-26 14:02:25
Message-ID: 404709.1695736945@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sorin Mircioiu <sorin(dot)mircioiu(at)gmail(dot)com> writes:
> I need answers to the following questions:

> 1. 13502 is blocked by 21544 and 21544 is blocked by 13502. Why PostgreSQL
> didn't detect this situation as a deadlock ?

You have not demonstrated that these two processes are waiting for
each other, only that they are waiting for something. The subset
of data you presented is insufficient to conclude that a deadlock
should have been reported. It does appear that some progress
has been made since the previous deadlock, since neither process
is waiting for the same thing it was waiting on as of the deadlock
report.

In the past we've seen cases where a deadlock existed but the
server could not detect it because one step in the waits-for
loop was implemented by client-side behavior rather than a
server-visible lock request. Not saying that's happened here,
but you might want to consider your application's behavior
with that idea in mind.

> why is ShareLock used for the locking system in my situation ?

ShareLock on an XID is a different thing from ShareLock on a table.
IIRC we request ShareLock on an XID as a way of waiting for the
transaction using that XID to terminate, which is a need that only
comes up in some edge cases like CREATE INDEX CONCURRENTLY. Have you
identified exactly what statements those functions are executing?

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2023-09-26 16:09:01 Re: BUG #18124: PG16 release note document bug in "Add build option to allow testing of small WAL segment sizes"
Previous Message David Rowley 2023-09-26 13:42:32 Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower