Re: How to investigate deadlocks

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Matthias Apitz <guru(at)unixarea(dot)de>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to investigate deadlocks
Date: 2023-10-02 22:25:02
Message-ID: CAKFQuwar-axQf=ms04+LqWgB+XJL_d9FELzjtYFcWaVj45jUQQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, October 2, 2023, Matthias Apitz <guru(at)unixarea(dot)de> wrote:

>
> Hello,
>
> One of our clients running our LMS on top of PostgreSQL 13.1 created a
> ticket with these messages:
>
> 2023-09-30 16:50:50.951 CEST [18117] ERROR: deadlock detected
> 2023-09-30 16:50:50.951 CEST [18117] DETAIL: Process 18117 waits for
> ShareLock on transaction 150396154; blocked by process 18187.
> Process 18187 waits for ShareLock on transaction 150396155;
> blocked by process 18117.
> Process 18117: fetch hc_d03geb
> Process 18187: fetch hc_d02ben
> 2023-09-30 16:50:50.951 CEST [18117] HINT: See server log for query
> details.
> 2023-09-30 16:50:50.951 CEST [18117] CONTEXT: while locking tuple (38,57)
> in relation "d03geb"
> 2023-09-30 16:50:50.951 CEST [18117] STATEMENT: fetch hc_d03geb
>
> The shown PIDs for sure are the ones of the Pos backend proc (on Linux).
> Is there any chance to investigate it further?
>

Presuming you control the software performing the fetches, sure. But the
database has pretty much told you all it can from its perspective. Start
from the two fetches, work out the table/row access ordering, and figure
out where you have the same pairs of tables being accessed but in different
orders.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2023-10-02 23:57:26 Re: How to force "re-TOAST" after changing STORAGE or COMPRESSION?
Previous Message MATSUO Takatoshi 2023-10-02 22:13:03 Re: Operating of synchronous master when no standby is available